PDA

View Full Version : Rotating the GraphicsItem while translating



ashishrai
25th May 2008, 19:02
Hi !!!! ,:)

I am implementing a simulator in Qt of objects moving on a table.
Hence it is required that I should also have an option to rotate the object while translating it.
Both can be done exclusively but how can we achieve it together.
I created a Graphics item and set its flag ItemIsMovable true and then in the keypressevent
if I get an 'r' pressed while the left button is pressed then I should rotate the object .
But this doesnt seem to work.
My object gets created always from the original position and since I use a static variable to store whether the mouse key is pressed or not, I can do this if I have only one item or I should create a array of the no of objects I should add.

Any help is greatly appreciated in the project!!
Thanks in advance.:)

jpn
25th May 2008, 20:20
My object gets created always from the original position and since I use a static variable to store whether the mouse key is pressed or not, I can do this if I have only one item or I should create a array of the no of objects I should add.
So why do you use a static variable? Why not an ordinary non-static member variable?

aamer4yu
26th May 2008, 06:04
Why cant both be done at same time ??

You can set the matrix for the graphics view. See QGraphicsView::setMatrix() and QGraphicsView::setTransform()


u can combine the matrix to get the desired effect.
Also I remember translation and rotation happening in Arthur PLugin example I guess/. Check the demos.

Hope this helps. :)