Retain mouse coordinates after Zoom in/out.
Unsolved
General and Desktop
-
I've a central widget with scaled axes . I'm getting the coordinates by using:
x = (event->pos().x()); y = (event->pos().y());
This is working fine. After zooming in or out, the coordinates still remain same. But from the point of view of central widget, it should get changed. How do I achieve this?
-
Hi
Well how do you zoom the central widget ?
You have to apply the same math to the mouse coordinates to
calculate a zoomed point. -
What @mrjj said. In (pseudo) code it's simply:
QPoint newCursorPos = oldCursorPos / oldZoomFactor * newZoomFactor;