QScrollArea: Avoiding initial delay to scrolling
-
Hi,
When you press down your mouse button on the arrow button at the end of a QScrollBar on a QScrollArea, the view nudges one bit, stops for a while and then begins continuous scroll.
My question: How can I get rid of the wait before the continuous scroll?
In the case of a normal button, the answer would probably be the QAbstractButton::autoRepeatDelay property. However, a QScrollBar lists no child widgets, so I wonder if there is any way to access the buttons of a QScrollBar.
The stylesheet system allows access to the end buttons of a scrollbar, but setting ”qproperty-autoRepeatDelay” didn’t seem to work — maybe because the qproperty thing is promised to work for ”DESIGNABLE” properties only.
Another approach would be to use the protected method QAbstractSlider::setRepeatAction, which takes thresholdTime and repeatTime as arguments. However, I haven’t managed to get it right.
I am using Qt 4.7.
Thanks for any help!
-
Hi,
You can create your own QScrollBar so you can use the protected function and then set it on the QScrollArea.
-
@sgaist Thanks for the comment. I got it working albeit the solution may be a little kludgy; I couldn't directly detect whether user's mouse click is upon one of the arrow buttons of a scrollbar, so I used a logic like this:
When a signal fires to indicate a single-step movement to either direction,
call QAbstractSlider::setRepeatAction to override the normal repetition pattern
by a pattern without the delay. However, that override must be done only once per mouse-press, so I overrode QScrollBar::mousePressEvent so as to set a "sensitivity flag" for that purpose.