Reputation: 2696
How do I detect a scroll event in a Qt widget?.
I want to use it to scroll a QWT plot. I have tried using a QMouseEvent
, but I could only find options for movement and pressing/releasing the mouse.
Upvotes: 11
Views: 17084
Reputation: 443
If you use vertical wheel mouse, you can catch wheel up or wheel down event using the below function. If you use horizontal wheel mouse, check ev->angleDelta().x()
value!
void wheelEvent(QWheelEvent *ev)
{
if(ev->angleDelta().y() > 0) // up Wheel
action1();
else if(ev->angleDelta().y() < 0) //down Wheel
action2();
}
Upvotes: 10
Reputation: 22346
void QWidget::wheelEvent(QWheelEvent* event)
will be what you are after (docs here).
Upvotes: 23