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 style vertical scrollBar of QcomboBox?
Forum Updated to NodeBB v4.3 + New Features

how to style vertical scrollBar of QcomboBox?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.8k Views
  • 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.
  • V Offline
    V Offline
    veer
    wrote on last edited by SGaist
    #1

    hi I am new to Qt and have average knowledge about Qt and its widget . I have used drop down comboBox , due to too many items in comboBox a vertical ScrollBar appears so I Want to style it. I tried to style it by setting its stylesheet as shown bellow but it is not working

    "QComboBox {"
                                            "background-color: rgb(231,233,234);"
                                            "border-top: none;"
                                            "border-left: none;"
                                            "border-right: none;"
                                            "border-bottom:1px solid rgb(138,147,155);"
                                             "color : rgb(72,79,83);"
                                            "}"
                                            "QComboBox::drop-down {"
                                            "width: 25px;"
                                            "border: 0px;"
                                            "color : rgb(72,79,83);"
                                            "}"
                                            "QComboBox::down-arrow {"
                                            "image: url(:/images/Dropdown.png);"
                                            "width: 8px;"
                                            "height: 8px; "
                                            "}"
                                            "QScrollBar:vertical{"
                                            "border-top: 8px solid #ffffff;"
                                            "border-bottom: 8px solid #ffffff;"
                                            "border-left: 8px solid #ffffff;"
                                            "border-right: 8px solid #ffffff;"
                                            "background: rgb(231, 233, 234);"
                                            "margin: 0px 0px 0px 0px;"
    //                                         "width :22px;"
                                            "}"
                                            "QScrollBar::handle:vertical {"
                                            "background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"
                                            "stop: 0 rgb(138, 147, 155), stop: 0.5 rgb(138, 147, 155), stop:1 rgb(138, 147, 155));"
                                            "min-height: 0px"
                                            "}"
                                            "QScrollBar::add-line:vertical {"
                                            "background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"
                                            "stop: 0 rgb(138, 147, 155), stop: 0.5 rgb(138, 147, 155),  stop:1 rgb(138, 147, 155));"
                                            "height: 0px;"
                                            "subcontrol-position: bottom;"
                                            "subcontrol-origin: margin;"
                                            "}"
                                            "QScrollBar::sub-line:vertical {"
                                            "background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"
                                            "stop: 0  rgb(138, 147, 155), stop: 0.5 rgb(138, 147, 155),  stop:1 rgb(138, 147, 155));"
                                            "height: 0 px;"
                                            "subcontrol-position: top;"
                                            "subcontrol-origin: margin;"
                                            "}";
    
    

    screen shot

    comboxScrollbar.PNG

    Although the final result should be shown below
    840cb2d1-d13f-4623-b5c8-c8baf70eb95d-image.png

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gary-1959
      wrote on last edited by
      #2

      The dropdown element is contained within a QAbstractItemView object, so to access the scroll bar in this use something like:

      QComboBox QAbstractItemView QScrollBar:vertical {
      background-color: green;
      color: black;
      }

      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