Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    3
    4
    1208
    Loading More Posts
    • 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.
    • L
      Leon last edited by

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

      !http://i.imgur.com/9zoCxwE.png(1)!

      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?

      1 Reply Last reply Reply Quote 0
      • G
        giesbert last edited by

        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.

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply Reply Quote 0
        • A
          andre last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • G
            giesbert last edited by

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

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

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply Reply Quote 0
            • First post
              Last post