mentalmushroom
2nd September 2011, 11: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
{
public:
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?
Here is my slider proxy style implementation:
#include <QProxyStyle>
class SliderProxyStyle : public QProxyStyle
{
public:
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?