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

Hover color of QComboBox is Not fixing ?



  • Hi I tried to fix the hover color of the comboBox but it is not working . I wan it to be something rgb(242,243,243 but it has default color i.e blue

    comboxhoverColor.PNG

        this->setStyleSheet(
                    "QLabel{ "
                    "font-family: Helvetica;"
                    "font-weight: normal;"
                    "font-size: 9pt;"
                    "color: rgb(72,79,83);"
                    "}"
    
                    "QComboBox {"
                    "background-color: rgb(255,255,255);"
                    "border-top: none;"
                    "border-left: none;"
                    "border-right: none;"
                    "border-bottom:1px solid rgb(138,147,155);"
                    "font-family: Helvetica;"
                    "font-weight: normal;"
                    "font-size: 9pt;"
                    "color: rgb(72,79,83);"
                    "}"
                    "QComboBox::drop-down {"
                    "width: 25px;"
                    "border: 0px;"
                    "color:rgb(72,79,83);"
                    "}"
                    "QComboBox::hover{"
                    "background: rgb(242,243,243);"
                    "}"
                    "QComboBox::down-arrow {"
                    "image: url(:/images/Dropdown.png);"
                    "width: 8px;"
                    "height: 8px; "
                    "}"
    
                    "QLineEdit {"
                    "background-color: rgb(255,255,255);"
                    "border-top: none;"
                    "border-left: none;"
                    "border-right: none;"
                    "border-bottom:1px solid rgb(138,147,155);"
                    "font-family: Helvetica;"
                    "font-weight: normal;"
                    "font-size: 9pt;"
                    "color: rgb(72,79,83);"
                    "}"
                    );
    


  • @veer
    Did you mean selection color ?
    Can you try with selection-background-color for your QComboBox ?



  • @veer
    Please refer to the doc: https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qcombobox
    What you want to set is not hover of QComboBox, but the selection of the pop-up, so it should be

    QComboBox QAbstractItemView {
        selection-background-color: rgb(242,243,243);
    }
    


  • @Bonnie thanks dear it works although I tried it earlier also but it didn't work at that time and since I was not sure about working of QAbstratItemView that's why I removed it . After your reply I knew that I have to work like this so I wondering why it is not working then, and fount that stylesheet is setting at more than one places . Anyway thanks man ……….


Log in to reply