How to map coordinates of QGraphicsScene to a PixmapItem that is moving and rotating (following a path)
-
Hi and welcome to devnet
I think you are using the wrong class in your case.
Check the Colliding Mice example.
-
@SGaist
Hello and thanks for the reply :)I just created a little code example to show my problem :)
I looked at the mice example and i don't understand how the mouse is positioned.
setRotation(rotation() + dx); setPos(mapToParent(0, -(3 + sin(speed) * 3)));
Why is the x value always 0 but the mouse can move right and left?
I also think that it is not quite comparable because i have given coordinates in the Scene my pixmap should follow while rotating.
The mouse rotates randomly (seems to me like that) and positions itself on the Scene.
I already tried mapFromParent. If i do that my Pixmap jitters and it doesn't follow the path.For a week i tried also Transforming (QTransform) and all that. Is their something else that i am missing?
-
The trick of the mouse to rotate is that the rendering is rotated independently from the item itself.
As for the movement, unless I am mistaken, it's always moving "horizontally" with respect to the item rotation rotation. Much like when you are walking, you are going forward, when you rotate you still go forward but with a different angle than before.