Stylesheets affecting widgets in unexpected way



  • Lately I've noticed changing the style sheets of either the main window, or any of the widgets, effects them in a way I don't expect. If I create a new project, then add some widgets in but don't change the style sheet, it runs as I would expect it to (looking like a windows 7 program). But if I change the style sheets, the widget's style changes to a windows XP sort of style. It never used to do this, and I'm wondering why it does it now?

    https://dl.dropbox.com/u/24424371/QT_01.jpg
    Before altering style sheets

    https://dl.dropbox.com/u/24424371/QT_02.jpg
    After altering style sheets..

    I've tried reinstalling Qt a number of times, but nothing worked. It compiles with MSVC2008, my old version (pre-format) compiled with mingw, which I can't get this version to do - would that have something to do with it?



  • note that stylesheet provides function only for customize object Not for coloring or changing the OS native style. you must use it on certain objects which you want to have a custom look. if you have trouble with styling a specific object try using dynamic properties as a filter
    http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-using-dynamic-properties

    in practice:
    add a dynamic property to your main widget using qt creator or in code
    @
    widget->setProperty("anyname",true);
    @

    then change the style sheet
    @
    QWidget[anyname='true']{
    ...
    }
    @

    every widget which has "anyname" property to "true" will get your style.



  • It's strange, it used to work just fine. I'm using python (which I forgot to mention earlier), and normally I wouldn't need to change anything in code, I could just go straight to the widget, right click and style sheets, and the colours would be changed (but not the actual button's style). I'm not sure how to access things like borders and so on within python, but I just wondered why it suddenly needs all this new attention when it worked fine before. Thanks for the quick reply btw.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.