I'm trying to style a combobox in QT5. I'm using QT Creator for the layout and loading an app-wide style sheet at start up.
The css I have related to my combobox is as follows:
QComboBox
{
color:white;
background-color: qlineargradient(x1:0, y1:0, x2:1,y2:1, stop: 1 rgba(228, 41, 81, 100), stop: 0 rgba(234, 107, 101, 100));
border-color: rgba(255,255,255,200);
border-width: 1px;
border-style: solid;
}
QComboBox QListView
{
border-style: none;
background-color: qlineargradient(x1:0, y1:0, x2:1,y2:0, stop: 1 rgba(228, 41, 81, 100), stop: 0 rgba(234, 107, 101, 100));
}
QComboBox::drop-down
{
width: 20px;
border: 1px;
border-color:white;
border-left-style:solid;
border-top-style: none;
border-bottom-style: none;
border-right-style: none;
}
QComboBox::down-arrow
{
image: url(:/ArrowImages/images/whitearrowdown16.png);
width: 16px;
height: 16px;
}
But the text colour in the combo box remainds as the default (black) colour. The colour in the drop down is white. The border colour and styling all work correctly. Is the label on the combobox some sort of sub-control I need to style separately? Or am I missing something else?
Thanks.
Edit:
Added screenshots for clarity
Edit 2: It looks like this only occurs when the combobox is set to not be editable (which is the correct behaviour for my program, so doesn't really help me.) When the combobox is set to editable, it obeys styles correctly. I've tried adding
QCombobox:!editable
{
color:white;
}
but it doesn't fix the problem.
QComboBox#YOUR_SPECIFIC_COMBO_BOX_NAME { color: white; }
– Patrizia