Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Best way to use "change styleSheet..." in Qt Designer?
Forum Updated to NodeBB v4.3 + New Features

Best way to use "change styleSheet..." in Qt Designer?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.5k 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.
  • M Offline
    M Offline
    mjsmithers
    wrote on last edited by
    #1

    Hi,

    I've been using the "change styleSheet.." feature in Qt Designer (by right-clicking on a widget) to change the background of QDialogs and tab pages; inserting, for example,

    #<widget name> {
    background-color: white;
    }

    however I find that setting the stylesheet appears to damage the style used by some child widgets within the dialogs. For example in QTableViews it resets vertical and horizontal header font sizes to be the same as the cell text font size, when it should be smaller.

    (If I change the background color in code, by modifying each widget's palette, the problems don't occur.)

    Does anyone know the correct syntax for setting stylesheet items in Qt Designer without damaging child widgets?

    The current behaviour seems to make the "Change styleSheet..." feature in Qt Designer useless...

    Best,
    Michael

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      Stylesheets are cascading by nature so they will affect child widgets if the selector matches,
      The best way to control it is by using one stylesheet on the application. and never used
      broad selectors like QWidget unless you really mean it.

      While developing the stylesheet i set it on the MainWindow as its top parent and own most of the widgets.

      M 1 Reply Last reply
      1
      • mrjjM mrjj

        Hi
        Stylesheets are cascading by nature so they will affect child widgets if the selector matches,
        The best way to control it is by using one stylesheet on the application. and never used
        broad selectors like QWidget unless you really mean it.

        While developing the stylesheet i set it on the MainWindow as its top parent and own most of the widgets.

        M Offline
        M Offline
        mjsmithers
        wrote on last edited by
        #3

        @mrjj Makes sense. But what I'm asking is how to properly set the properties I care about, without damaging or clearing other properties.

        mrjjM 1 Reply Last reply
        0
        • M mjsmithers

          @mrjj Makes sense. But what I'm asking is how to properly set the properties I care about, without damaging or clearing other properties.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @mjsmithers
          well if you put a style sheet on a Widget, it disables the normal drawing so you have to style it fully.
          But can you give an example of something that goes wrong ?

          M 1 Reply Last reply
          0
          • mrjjM mrjj

            @mjsmithers
            well if you put a style sheet on a Widget, it disables the normal drawing so you have to style it fully.
            But can you give an example of something that goes wrong ?

            M Offline
            M Offline
            mjsmithers
            wrote on last edited by
            #5

            @mrjj There's an example in the OP above.

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              if you use good selectors, it should
              only affect the widgets you target.

              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