Results 1 to 2 of 2

Thread: QSS stopped working when using QProxyStyle

  1. #1
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default QSS stopped working when using QProxyStyle

    Hello, I'd like to make the QSlider position set where I clicked with the mouse. As it was suggested here 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:
    Qt Code:
    1. #include <QProxyStyle>
    2.  
    3. class SliderProxyStyle : public QProxyStyle
    4. {
    5. public:
    6.  
    7. explicit SliderProxyStyle(QStyle *baseStyle = 0) : QProxyStyle(baseStyle)
    8. {
    9. }
    10.  
    11. int styleHint(QStyle::StyleHint hint, const QStyleOption* option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData = 0) const
    12. {
    13. if (hint == QStyle::SH_Slider_AbsoluteSetButtons)
    14. return (Qt::LeftButton | Qt::MidButton | Qt::RightButton);
    15. return QProxyStyle::styleHint(hint, option, widget, returnData);
    16. }
    17.  
    18. };
    To copy to clipboard, switch view to plain text mode 

    And this is how I use it:
    Qt Code:
    1. QSlider * playbar = new QSlider(Qt::Horizontal);
    2. playbar->setStyle(new SliderProxyStyle(playbar->style()));
    To copy to clipboard, switch view to plain text mode 


    Is it possible to use QProxyStyle along with QSS styling?

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: QSS stopped working when using QProxyStyle

    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.
    Don't write a post just to thank someone, use "Thanks" button.

Similar Threads

  1. Stopped widget in a moveable QGraphicsScene
    By jano_alex_es in forum Newbie
    Replies: 3
    Last Post: 4th February 2011, 10:05
  2. Replies: 12
    Last Post: 9th January 2011, 13:51
  3. Replies: 1
    Last Post: 29th July 2010, 05:41
  4. QResource Stopped Working
    By JPNaude in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 12:26
  5. Signals/Slots stopped working
    By Jimmy2775 in forum Qt Programming
    Replies: 8
    Last Post: 31st March 2006, 21:11

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.