Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Get Mouse local position on key press event
RiccardoTurati last edited by
I would like to retrive mouse local position inside a key press event.
How could i do?
I have used QCursor::pos(); , but it gives me only the global position.
Anyone could help me?
Thank you all.
You could enable mouseTracking in the widget you're interested in, and have its mouseMoveEvent update a local QPoint member variable as the mouse moves. Then you could just read the latest position from that variable in the keyPressEvent.