View Full Version : QSS stopped working when using QProxyStyle

2nd September 2011, 12:43
Hello, I'd like to make the QSlider position set where I clicked with the mouse. As it was suggested here (http://www.qtcentre.org/threads/9208-QSlider-step-customize) I implemented the proxy style and applied it to my QSlider instance. In my application QSlider is styled with QSS. If I apply the implemented proxy style QSS styling stops working, although I don't change anything related to drawing there.

Here is my slider proxy style implementation:

#include <QProxyStyle>

class SliderProxyStyle : public QProxyStyle

explicit SliderProxyStyle(QStyle *baseStyle = 0) : QProxyStyle(baseStyle)

int styleHint(QStyle::StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const
if (hint == QStyle::SH_Slider_AbsoluteSetButtons)
return (Qt::LeftButton | Qt::MidButton | Qt::RightButton);
return QProxyStyle::styleHint(hint, option, widget, returnData);


And this is how I use it:

QSlider * playbar = new QSlider(Qt::Horizontal);
playbar->setStyle(new SliderProxyStyle(playbar->style()));

Is it possible to use QProxyStyle along with QSS styling?

2nd September 2011, 13:00
It is not possible to combine QSS and QStyle. It is written in QWidget documentation under stylesheet property:

Warning: Qt style sheets are currently not supported for custom QStyle subclasses. We plan to address this in some future release.