I want to rotate the object not using story board.. in story board have from and to property it's easy. But i want first time click rotate that time rotate 90 deg at the same time click rotate rotate 180, and so on till 360....... simply i want each time of you click rotate that time rotate 90 deg....
I wnat this type of screen for each time of click rotate button......
please help me....
Thanks In Advance.....
Use a RotateTransform: http://msdn.microsoft.com/en-us/library/system.windows.media.rotatetransform%28v=vs.95%29.aspx
In your code you can use it like this:
((RotateTransform)YourImageObjectName.RenderTransform).Angle = x;
Related
I am hoping to be able to open and close a tester lid automatically after an agent has been inserted.
If possible a rotating lid would work great but I have only been able to rotate around the Z axis.
You can add the lid's animation into a Group (right-click -> "add to group"). You can then rotate the entire group around the x, y and z axis.
I'm using pyqtgraph PlotWidget to draw something, that works well. But when I want to rotate the "view".
Here is the first pic, degree 0:
[1]: https://i.stack.imgur.com/gQnGd.png
Then after rotate with transform(codes later), degree 40 as example:
[2]: https://i.stack.imgur.com/qX12z.png
As marked in pic2, actually, after rotation, the "out of view" area is supposed to be filled with the grid and the item in invisible area of pic1 would show too.
Code:
#plotwidget initialized in ui file with a QFrame parent,
#which also the parent of buttons and sliders.
range = QRectF(0, 0, self.plotwidget.size().width(), self.plotwidget.size().height()).center()
transform=self.plotwidget.transform()
transform.translate(range.x(),range.y())
transform.rotate(angle)
transform.translate(-range.x(),-range.y())
self.plotwidget.setTransform(transform)
I checked the api of QGraphicsScene and QGraphicsView, only QGraphicsView has the rotate method, which actually the same as "rotate" with transform.
So I think the rotate of QGraphicsView or PlotWidget actually rotate the view widget itself and the QGraphicsScene in it meanwhile. But how to rotate the scene only?
Thanks for your help ahead.
I have a single image that is displayed inside a scrollRect.. pivot is centered and the user is able to scale the image up and down using a slider.. then he/she is able to scroll drag the image around (with the scrollRect functionality) like for example a page in a book-app.. but when the user scales the image up and drags it around and then scales it back down again, the page shrinks at its own pivot point and sometimes gaps are visible on the sides depending on where the user has dragged the image.. When you start to drag the image again it snaps to the correct location but it doesn't look very polished when you force a user to "nudge" something before it snaps into place..
does anybody know of a way to invoke the "nudge" after scaling? Or force the ScrollRect to calculate the position of the image after scaling? I tried using math and pivot points but since the position alters with both scaling and dragging I can't hardcode a value to change pivot points (like f.e. if x < -50 and y < -50 then the pivot point should be top right) ..
The simplest solution would be to invoke that little nudge the user has to do now but I don't know how I have to go about doing it (just changing the transform.positon.x in code doesn't work, the scrollRect needs to update its content) or maybe I could reset the position of the anchor so it stays at the center of the parent..
I tried to clarify with some images:
https://ibb.co/f7Oxk6
I need to rotate a Image box 55 degrees when a condition in my if statement is met. Is this possible?
I think it is possible to rotate an image by using Windows API.
Can you have a look on Rotate Images in PictureBoxes?
I was able to get the information about the image first(width and height), and next, I want to get the coordinate about certain point on the image and record the information by a mouse click. How can I do that? I am using Qt.
Thanks !
1 - map the click coordinates to the image coordinates, that will give you the position you clicked on the image.
2 - after that you can use QImage::pixel(x,y) to get the RGB value for the pixel at that coordinate.