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. Stylesheet code for two different QScrollBars

Stylesheet code for two different QScrollBars

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 354 Views 1 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.
  • DejanPetrovicD Offline
    DejanPetrovicD Offline
    DejanPetrovic
    wrote on last edited by
    #1

    I know that if you want to make specific stylesheet for some control you should set something like this:

    #PushButton1{
    color: red;
    }
    #PushButton2{
    color: blue;
    }
    

    But what if you want to make same thing for two different QScrollBars, for example one that belong to ListWidget1 and another to ListWidget2 ? What should I write as stylesheet code?

    JonBJ 1 Reply Last reply
    0
    • DejanPetrovicD DejanPetrovic

      I know that if you want to make specific stylesheet for some control you should set something like this:

      #PushButton1{
      color: red;
      }
      #PushButton2{
      color: blue;
      }
      

      But what if you want to make same thing for two different QScrollBars, for example one that belong to ListWidget1 and another to ListWidget2 ? What should I write as stylesheet code?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @DejanPetrovic
      You can use Descendant Selector and Child selector, as per https://doc.qt.io/Qt-5/stylesheet-syntax.html#selector-types.

      I'm not sure of my # syntax, but something like these two examples.:

      #ListWidget1 #PushButton1 { ... }  /* A `#PushButton1` anywhere inside `#ListWidget1` */
      
      #ListWidget2 > QPushButton { ... }  /* Any `QPushButton` directly on `#ListWidget2` */
      
      1 Reply Last reply
      1
      • DejanPetrovicD Offline
        DejanPetrovicD Offline
        DejanPetrovic
        wrote on last edited by DejanPetrovic
        #3

        Thanks for replay, that link explains a lot. Descendant Selector working for me. But now something weird is going on. In Designer now is OK but in final application it doesn't apply as it's showed in picture.
        What should I do?
        Annotation 2020-06-03 222115.jpg

        Plus all fonts suddenly becomes bold. So weird.

        1 Reply Last reply
        0
        • DejanPetrovicD Offline
          DejanPetrovicD Offline
          DejanPetrovic
          wrote on last edited by
          #4

          Solved: That issue about fonts becoming bold is causes two splitters. I don't know why but when remove one splitter all is OK

          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