Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Disable slider of scrollbar in scrollarea
Is it possible to disable the slider of a scrollbar in a scroll area?
I've styled the scrollbar using css to show the arrows next to the slider. I did this by setting a width on the scrollbar, and using margins to make the slider more narrow. While this looks good, now the margin itself also responds to drag/click events. This is not what I want.
Is there any way to disable the slider, or make the slider respond to a smaller area?
Thanks in advance!
Ratzz last edited by
No, the scrollbar is needed, I only want the arrows to respond to events, not the slider.
You could apply an event filter to the scrollbars
and eat those "clicks" that are outside your wanted area.
or you could subclass QScrollBar and override mouse event function
to alter how mouse press works.
You can disable the scrollbars with
but that prevents any clicking.
That sounds useful! Now I'm wondering how to detect the correct area. The public API doesn't really help me, but perhaps I'm missing something obvious.
The "actionTriggered" event seems to happen after updated the position, but before updating the UI. At his point I've already lost the current position (unless I use the "valueChanged" signal to keep track. But I hope there is an easier way to do this..
If you look here
you can see the use of
QRect groove = proxy()->subControlRect(CC_Slider, slider, SC_SliderGroove, widget);
QRect handle = proxy()->subControlRect(CC_Slider, slider, SC_SliderHandle, widget);
I assume you can get the various parts this way, even you changed it using stylesheet.