Unsolved Retain mouse coordinates after Zoom in/out.
-
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;
-
I'll restate the problem:
When I zoomed in and hover on the upper left corner, the location should NOT be 0,0 (the QMouseMouseEvent just gives me this point). I want the coordinates relative to the central widget.