PDA

View Full Version : [Solved] QEvent::MouseMove problem



fiodis
16th November 2012, 18:22
I have an OpenGL 3.1 context drawing inside a generic QWidget promoted to a QGLWidget (not a QGraphicsView, I think). I need to find the mouse cursor position every time the mouse moves, so I can redraw some objects with updated coordinates. I've implemented the mouseMoveEvent event handler, but the problem is that it only registers if the mouse button is held down (clicking and dragging). This is not what I need; I have a seperate function called on mouse click, and I don't want it called just to detect the mouse moving.

So my question is this: is there any way I can get an event for when the mouse is moved inside my Widget, even if the mouse button is not being held down?

high_flyer
16th November 2012, 19:19
Why not read the docs?

If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.

http://doc.qt.nokia.com/latest/qwidget.html#mouseTracking-prop

amleto
16th November 2012, 19:23
qwidget.html#mouseTracking-prop

edit:
ow, beaten.

fiodis
16th November 2012, 21:15
:eek:
How did I miss that? It works perfectly, thank you!