Unsolved QListWidget: Vertical Scroll Bar and Mouse Wheel
-
Hi all,
I am currently designing a general properties Editor in which one contains a QListWidget (for storing different type of data).
So the QListWidget is inside the widget Editor.
I would have thought that using the mouse wheel above the QListWidget would automatically drag the vertical scroll bar, but it doesn't. I don't know why. And I can't figure it out.
I tried to re implement a "QListWidgetPlus" inheriting QListWidget and add my how "wheel mouse action" method, but it still wasn't working.
bool QListWidgetPlus::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::Wheel) { QWheelEvent *wEvent = (QWheelEvent *)event; wEvent->delta()>0 ? verticalScrollBar()->setValue(verticalScrollBar()->value() + 1) : verticalScrollBar()->setValue(verticalScrollBar()->value() - 1) ; } return false; }
So I resume : I have a QListWidget (inside an Editor) and I would like that this list widget scrolls down as soon as I use the mouse wheel.
Do you know how to do this ? What am I missing ?
Thank you in advance for your time. :-)
-
@yannickBAT
why do you handle the wheel event yourself in the first place? This is already implemented by default by QAbstractScrollArea derivatives.
Depending on the size of the scroll area increasing the value by 1 might not be noticable. -
@raven-worx said in QListWidget: Vertical Scroll Bar and Mouse Wheel:
@yannickBAT
why do you handle the wheel event yourself in the first place? This is already implemented by default by QAbstractScrollArea derivatives.I handle the wheel event myself because it doesn't work (and I don't know why) for my QListWidget which is inside a bigger QGraphicsProxyWidget.
So as it didn't work, I decided to handle it myself this way.
Depending on the size of the scroll area increasing the value by 1 might not be noticable.
I'll try with higher values, then!
Thank you
-
@yannickBAT said in QListWidget: Vertical Scroll Bar and Mouse Wheel:
my QListWidget which is inside a bigger QGraphicsProxyWidget
well thats some crucial information no?
Does your QGraphicsView show scrollbars?I'll try with higher values, then!
simply check if it is called at all first (e.g. with a debug print).
-
well thats some crucial information no?
Yes. This is why I was trying to explain when I said:
So I resume : I have a QListWidget (inside an Editor) and I would like that this list widget scrolls down as soon as I use the mouse wheel.
on my first message. I should have told that this Editor was a QGraphicsProxyWidget, though. Sorry about that.
Does your QGraphicsView show scrollbars?
It does. And I can move the scroll bar manually with a mouse click and mouse move. Looks like it:
simply check if it is called at all first (e.g. with a debug print).
As you assumed, my event filter function is not called at all.