How to set qss property back to its default value?

  • 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":

    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);
    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?


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

  • 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 ...


    it will revert to the default style

  • 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.

  • 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.

Log in to reply