Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Stylesheets affecting widgets in unexpected way
Forum Updated to NodeBB v4.3 + New Features

Stylesheets affecting widgets in unexpected way

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Boonze
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mohsen
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Boonze
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved