Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

how to style vertical scrollBar of QcomboBox?



  • 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


Log in to reply