PDA

View Full Version : Mouse lock inside window/widget



carbiii
5th March 2013, 07:16
I am trying to stop the mouse from leaving the window. This is useful for first person cameras in OpenGL, as well as full screen applications with multiple monitors. I mostly am just looking to keep it inside the window, however keeping the mouse inside a widget could also be useful to know.

sedi
5th March 2013, 08:47
http://qt-project.org/doc/qt-4.8/qwidget.html
You are looking vor leaveEvent().

So: just reimplement the leaveEvent, grab your mouse pointer by its neck and put it back where it belongs, I'd say.
For that: http://qt-project.org/doc/qt-4.8/qcursor.html (http://qt-project.org/doc/qt-4.8/qcursor.html)
But done that I never have....