Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.6.3, 5.12.0, 6.5
-
None
Description
QGraphicsViewPrivate::lastMouseMoveScenePoint is updated inside: mouseMoveEventHandler, contextMenuEvent, mouseDoubleClickEvent, mousePressEvent, mouseReleaseEvent; but not inside: wheelEvent.
Because mouseMoveEventHandler is not called when the window is out of focus (to update the mouse position), AnchorUnderMouse will not work to zoom in/out using wheelEvent (see #https://www.qtcentre.org/threads/52603-Zoom-effect-by-mouse-Wheel-in-QGraphicsview?p=264264#post264264).
As consequence, zoom in/out with QGraphicsView::scale works perfectly as long as the application window has the focus. Once it is lost to another application, QGraphicsView will do it using lastMouseMoveScenePoint which was set before the window lost its focus. The user expects it to zoom in/out using the current mouse cursor as the center of the transformation, and not an almost random position.
As a solution, updating lastMouseMoveScenePoint inside wheelEvent (as it happens with all other event handlers cited above) or scale, should be enough to fix this issue.
This bug is related to QTBUG-60672