PDA

View Full Version : QWheelEvent: checking if wheel has stopped



papillon
29th September 2011, 23:57
I have a QWheelEvent and I use it to zoom a QGLWidget scene in and out. Is it possible to intercept when the mouse wheel has stopped, something similar to mouseReleaseEvent(QMouseEvent *event) ?

Thanks

wysota
30th September 2011, 05:59
The wheel will have stopped when you stop receiving wheel events. Just run a timer that is reset in every wheel event and when it times out, you'll know the user stopped scrolling.

papillon
30th September 2011, 10:37
Thanks wysota, I have difficulties understanding this.

Shall I actually timer->start(0) in my main loop, and call again timer->start(0) in the wheelevent routine to restart the timer again?

wysota
30th September 2011, 13:00
No, zero timeout timer is not correct. Set the timeout to something like 500ms (or less if you want the mechanism to be more responsive at the cost of having some false positives).

papillon
30th September 2011, 13:03
Thanks wysota, infact now it's working perfectly!