Important: Please read the Qt Code of Conduct -

QComboBox + QSS + setting text color [Solved]

  • Hi! Surely an easy question here...

    I'm changing the text color of a QComboBox using a style sheet from black to white. The problem I'm facing is that, when the QComboBox contents drop down, the (white) text can't be read due to the also white background.

    So... how can I change the text color of current AND any other option of the QComboBox? Or, conversely, how can I change the background color only when the QComboBox is "on" (drop-down'd)?

    EDIT: for example: Normally, the QComboBox has white text, grey background. When drop-down'd, it has white text and white background. I would like it to have black text and white background when drop-down'd. Also could do great with white text and grey background.

    Thanks a million!


  • The drop down is a QListView that is a child of the QComboBox. That means that you can also style it as such. See the documentation for the styleable properties of QListView.

  • Back here again, ready to tag the post as SOLVED!

    This piece of QSS sets the text's color to black, while the background remains white.

    @QComboBox QListView {
    color: black;
    /*alternate-background-color: green;

    (thanks, Andre!!)


  • You can add that tag yourself. Simply edit your first message, and modify the subject line. I've done it for you this time, but next time, please do that yourself. Glad you got your issue solved!

Log in to reply