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 apply style sheet to nested properties?
Forum Updated to NodeBB v4.3 + New Features

How to apply style sheet to nested properties?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 434 Views 2 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.
  • T Offline
    T Offline
    Thinium
    wrote on last edited by Thinium
    #1

    If we want the property to apply only to one specific instance, we can specify the object name in the style sheet.

    // the style sheet will only apply to the object called evilButton

    QPushButton#evilButton { background-color: red }
    

    What if I want the following property to also be used by a specific object? I noticed that if I wrote QScrollBar#evilScroller:vertical, the style isn't applied at all.

    QScrollBar:vertical{
          background:palette(base);
          border-top-right-radius:2px;
          border-bottom-right-radius:2px;
          width:16px;
          margin:0px;
        }
    
    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      You have a QScrollBar named "evilButton"?

      T 1 Reply Last reply
      0
      • B Bonnie

        You have a QScrollBar named "evilButton"?

        T Offline
        T Offline
        Thinium
        wrote on last edited by
        #3

        @Bonnie hahaha! Nope, sorry it's a bad example. I renamed it now. But I realize that the scrollers are automatically created by QGraphicScene and I've only set the window's objectName but not the scroller's object name. I don't know if I can actually set the scrollers' object names manually as QGraphicScene doesn't seem to have a function to access it's scrollers.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bonnie
          wrote on last edited by
          #4

          That's what I think.
          We usually don't create a QScrollBar. They come with other container widgets.
          So you probably did not use the right object name.
          If it really has a object name of "evilScroller", I think the style sheet should work.

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

            Hi
            I assume you mean on QGraphicsView as QGraphicScene is nonvisual so I will be hugely surprised if it has scrollbars :)

            In any case, if i set on the view, its used when scrollbar shows up
            alt text

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved