Important: Please read the Qt Code of Conduct -

Applying a certain stylesheet at the mainwindow, will also be applied to any QWidget in that window

  • So i had set the mainwindows stylesheet as:
    @border-image: url(:/icons/Pictures/Background.png) 4 4 4 4 stretch stretch;@


    In the above screenshot u can see
    2 spacers
    a Qwidget
    inside of the Qwidget a label

    The qwidget has stylesheet
    @QWidget {\nbackground-color: black;\n}@

    but u can see that the background is not black... why is that?

  • Hi,

    style sheets are always also valid for derived classes.
    But you have moire options for the selector, so if your main windows class has a special name (or a special class) use that as selector and it does what you want. Have a look at the style sheet documentation.

  • Not only for derived classes, but especially for child objects. That's why they are called cascading: any style you set on a parent object, will propagate down towards child widgets too. There is no way to stop that from happening, other than to use a more specific selector for the parent style so that it does not apply to the child widgets you don't want it to apply for.

  • [quote author="Andre" date="1359996737"]Not only for derived classes, but especially for child objects. [/quote]

    Ups, thats what I wanted to say... :-)

Log in to reply