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. stylesheet in form file

stylesheet in form file

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 2.0k 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.
  • MegamouseM Offline
    MegamouseM Offline
    Megamouse
    wrote on last edited by
    #1

    Hi guys,

    We have set the background color of a single widget in one of the dialogs' form files to white.

    We use global stylesheets that are applied from qsettings on start of the application or on choosing from a settings dialog and clicking a pushbutton.

    Now we have the problem that the style that was set in the form file will not be changed by this global stylesheet.
    So for example every widget has black background except for this single white one.

    How would I achieve that it can be changed from the global stylesheet?

    Or do I have to make a "default" global stylesheet that only contains those special widgets?

    Thx,
    Megamouse

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

      In a style sheet you can use both names and types
      So i would use one global stylesheet and target the special widgets by type or by name.
      http://doc.qt.io/qt-5/stylesheet-reference.html

      Like
      setStyleSheet("QLineEdit#nameEdit { background-color: yellow }");

      only the QLineEdit called nameEdit will be affected.

      MegamouseM 1 Reply Last reply
      0
      • mrjjM mrjj

        In a style sheet you can use both names and types
        So i would use one global stylesheet and target the special widgets by type or by name.
        http://doc.qt.io/qt-5/stylesheet-reference.html

        Like
        setStyleSheet("QLineEdit#nameEdit { background-color: yellow }");

        only the QLineEdit called nameEdit will be affected.

        MegamouseM Offline
        MegamouseM Offline
        Megamouse
        wrote on last edited by
        #3

        @mrjj

        We tried that, but the style set in form files is applied on executing the dialog and overwrites the global stylesheet.
        If that makes sense.

        mrjjM 1 Reply Last reply
        0
        • MegamouseM Megamouse

          @mrjj

          We tried that, but the style set in form files is applied on executing the dialog and overwrites the global stylesheet.
          If that makes sense.

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

          @Megamouse
          Hi
          It only makes sense if style sheet is set on application level and not on the dialog.
          As far as i know they are not mixable and a given widget will only be affected by one
          style sheet at a given time. So if you set a local stylesheet in dialog, the global is only
          in effect "outside".

          MegamouseM 1 Reply Last reply
          0
          • mrjjM mrjj

            @Megamouse
            Hi
            It only makes sense if style sheet is set on application level and not on the dialog.
            As far as i know they are not mixable and a given widget will only be affected by one
            style sheet at a given time. So if you set a local stylesheet in dialog, the global is only
            in effect "outside".

            MegamouseM Offline
            MegamouseM Offline
            Megamouse
            wrote on last edited by
            #5

            @mrjj okay thx.

            so what would be the easiest way to settle this?
            use default global with those few changes?

            Someone told me to use properties instead.
            I haven't looked into that yet though

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Swerved
              wrote on last edited by
              #6

              Your best bet really is to remove the stylesheet from the forms entirely and go with a global stylesheet, in my opinion.

              If you are using the stylesheets as a 'skin' type option then simply provide a default one to be used if a custom one isn't selected by the end user.

              MegamouseM 1 Reply Last reply
              0
              • S Swerved

                Your best bet really is to remove the stylesheet from the forms entirely and go with a global stylesheet, in my opinion.

                If you are using the stylesheets as a 'skin' type option then simply provide a default one to be used if a custom one isn't selected by the end user.

                MegamouseM Offline
                MegamouseM Offline
                Megamouse
                wrote on last edited by
                #7

                @Swerved yeah that's what i use now.
                It's only a few lines anyway so I can just add it in my slot function without extra default qss.
                It's just a bit sad that I can't see it directly in form.

                thx this is resolved for my needs.

                would be nice to have better ways though. Maybe !important should be added sometime

                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