PDA

View Full Version : Scrolling the mouse over a QScrollbar



tuli
19th March 2015, 13:55
Why does mouse-scrolling over a QScrollBar emit a SliderChanged action, not a SliderSingleStepAdd/Sub action? Seems a little odd. Are there any better options for changing this than inheriting from QScrollbar?

d_stranz
19th March 2015, 16:33
What do you mean by "mouse-scrolling over a QScrollbar"? Do you mean grabbing the slider and moving it? Or putting the cursor on the bar and rolling the mouse wheel?

If you mean the mouse wheel, a single "click" of the mouse wheel is not the same as a mouse click on the up / down arrows at the end of the scrollbar. The wheel generates QWheelEvent events, not mouse clicks. QScrollbar handles the wheelEvent() and maps these into slider position changes. If you don't like this, derive your own class from QScrollbar and override wheelEvent() to implement your own (nonstandard and probably confusing to the user) behavior.