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. How to set qss property back to its default value?

How to set qss property back to its default value?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 7.2k Views
  • 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.
  • O Offline
    O Offline
    old9
    wrote on last edited by
    #1

    I'm stying the QProgressBar using qss:
    @QProgressBar::chunk {
    background-color: #FF0000;
    width: 6px;
    margin: 1px;
    }@
    this piece of code is just similar to the "qt styesheet sample page":http://doc.qt.nokia.com/4.6/stylesheet-examples.html#customizing-qprogressbar

    and then I have a special QProgressBar to overwrite this style define, actually, I don't need the grid effect this time, so I set the margin to 0, and when I tried to set the width back to its default value, I got stuck.
    the code is something like this:
    @QProgressBar#someSpecialBar::chunk {
    background: url(:/bg.png);
    margin:0;
    width: ???;
    }@
    I searched around and tried the values auto/none/0/initial/default/whatever and had no lucky here, it just wont give me the right effect, when the width is not specified.
    Anyone have any suggestions on this?

    Thanks!

    1 Reply Last reply
    1
    • O Offline
      O Offline
      old9
      wrote on last edited by
      #2

      Uhhh, I just found a value, -1, which will set it back to default, at least for the width property in this particular situation...

      H 1 Reply Last reply
      1
      • ? This user is from outside of this forum
        ? This user is from outside of this forum
        Guest
        wrote on last edited by
        #3

        ok not sure if I understood your question fully ...

        You have set a qss to your app and then you have overridden it in your progress bar and now to reset the style of the progress bar to the default, you just need to do this ...

        @
        myprogressbar->setStyleSheet("");
        @

        it will revert to the default style

        1 Reply Last reply
        0
        • O Offline
          O Offline
          old9
          wrote on last edited by
          #4

          Thanks for your reply
          This is what I actually mean, just to be clear:
          I get a qss file for styling the whole interface, in which I have many process bars.
          But there is one of them, that I need to style in a different way, and want to do that in the same qss file.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            ad5xj
            wrote on last edited by
            #5

            Be sure to check the custom stylesheets section of the docs. I notice some stylesheet settings require you to use all attributes for the object when specifying custom stylesheet attributes.

            Ken AD5XJ

            1 Reply Last reply
            0
            • O old9

              Uhhh, I just found a value, -1, which will set it back to default, at least for the width property in this particular situation...

              H Offline
              H Offline
              HowitzerDev
              wrote on last edited by
              #6

              @old9 The -1 worked perfectly for me for qtoolbar width. I didn't see this documented anywhere and needed it badly. Thank you.

              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