Hello there!
I'm drawing a couple of objects on the screen in the paintEvent() method of a QWidget. But before I start drawing, I apply a couple of transformations to the QPainter, such as translating the origin of the coordinate system to the middle of the screen and flipping the whole thing upside down. In the end, there is also a dynamic translation that is calculated at draw time to make the screen follow the objects.
Now, the objects are mouse sensitive and when I want to detect which object has been clicked, I need to translate the mouse pointer coordinates to my own coordinates. I do this by grabbing the QTransform from the QPainter at the end of the paintEvent() and saving it as a member of QWidget. When the mousePressEvent() occurs, I apply the inverse of the QTransform to the mouse pointer coordinates and there I have it.
So, my short question after a long introduction is: can I get the last applied QTransform in a more elegant way, than keeping track of it myself?
Thanks,
Cruz
Bookmarks