PDA

View Full Version : Override QScrollbar using QStyle



Alundra
20th June 2014, 17:35
Hi all,
Since Qt has problem with QScrollbar and stylesheet (My bug report : https://bugreports.qt-project.org/browse/QTBUG-39513), the only way who stays is to use QStyle.
I want to have a scrollbar like that : http://www.qtcentre.org/threads/27908-Styling-background-of-QScrollBar.
As you can see it's a line and the handle on it, but stylesheet doesn't allow background-image so it's impossible.
What is the good way to use QStyle to have a scrollbar like that ?
Maybe it's just not possible using Qt ?
Thanks for the help

anda_skoa
20th June 2014, 17:51
All widgets are painted using QPainter, so can be drawn using QPainter, it can be the visualization of a widget.

Cheers,
_

Alundra
20th June 2014, 18:12
Ok I see but Qt has a way to set this custom scrollbar widget to be the default scrollbar for all ?

anda_skoa
20th June 2014, 19:26
A QStyle set with QApplication::setStyle() affects all instances of a given widget class unless it is specifically making exceptions.

Cheers,
_

Alundra
20th June 2014, 22:14
Sounds good ! So a QStyle can be used to have default scrollbar until one is set in stylesheet if I understand correctly.

anda_skoa
21st June 2014, 12:11
A style and stylesheets are two entirely different things, but similar to a stylesheet a style can be set on a specific widget or application wide and it can decide to handle each instance of a widget individually.

Cheers,
_