Search code examples
c++cssqtstylesheetqcombobox

QComboBox text color doesn't change as expected


I have a simple QComboBox but I cannot figure out how to change the text color of the selected item. It stays black but it should be white. I used the color:white; properties but it seems to affect only the color of the popup item list.

this is my current stylesheet:

background: rgb(61,61,61);
color: rgb(255,255,255);
selection-color: rgb(255, 255, 255);

the QComboBox keeps having this behaviour:

enter image description here

enter image description here

as you can see the selected item still has an unspecified black color.


Solution

  • I have solved this by including the padding property:

    QComboBox { combobox-popup: 0; color: white; padding: 0px 0px 0px 0px; }

    It seems setting the padding property (with any value) on the combobox in the style sheet makes it properly obey the colour styling.

    See for reference: https://stackoverflow.com/a/24824810/4022402