View Full Version : Help with QWheelEvent

8th March 2013, 18:22
I need to change values in a line edit with the mouse wheel. Can't seem to find any examples of using the wheelEvent on line edit and the doc isn't helping me much.
Any pointers on how to do this?


10th March 2013, 11:06
For any kind of custom event handling, one usually creates a new class which is a sub class of the one need, in your case derive from QLineEdit.

Then you can override event handling by reimplementing protected event handling methods, in your case wheelEvent(QWheelEvent*).
The QWheelEvent class has a method called delta() which is either greather than 0 or less than zero, basically a value how "far" the wheel has been turned in either direction.

There is also the option of installing an event filter on the widget instead of subclassing, but usually having a concrete class with the new functionality is better in the long run.