@
Joel-Bodenmann
Thaks for replying!!
But It does not work for me.
Because I have a wheel event where I use it for doing zoom in or zoom aout in scene.
So I would like just remove wheel event for scrolling bars
Oh sorry, that's my bad. I just got up - should have paid more attention. Sorry!
As far as I can tell the
QScrollBar
doesn't have a property to enable/disable the wheel handling either. So you would do the same thing but just for your scroll bars instead of your graphics view. However, that would require you to implement your own scroll bar subclass which might not be that fancy of a solution. Assuming that you already have a subclass of
QGraphicsView
you might want to consider to install an event filter on the scroll bars instead to filter out the wheel events for the scroll bars. Something along the lines of (untested):
bool MyGraphicsView::eventFilter(QObject* object, QEvent* event)
if (object == verticalScrollBar() && event->type() == QEvent::Wheel) {
return true;
if (object == horizontalScrollBar() && event->type() == QEvent::Wheel) {
return true;
return false;
And in the constructor of the view subclass:
MyGraphicsView::MyGraphicsView(QWidget* parent) : QGraphicsView(parent)
verticalScrollBar()->installEventFilter(this);
horizontalScrollBar()->installEventFilter(this);
I hope I got it right this time ;)