1. Problem description
When setting the qss style on the QComboBox/QCheckBox in the Ubuntu (currently tested Ubuntu14.04, virtual machine VMware14) system, setting the color attribute on it does not take effect or the QComboBox only takes effect on the drop-down list.
1. The editor only sets the color attribute (as shown below).
QComboBox {
color: rgb(255, 0, 0);
}
QCheckBox {
color: rgb(255, 0, 0);
}
2. In the normal state of running
QComboBox itself, the font color does not change, and the set color attribute is invalid at this time (as shown in the figure below).
But after expanding the QComboBox, it is found that the font color of the item in the drop-down box changes.
2. Solutions
1. Add the padding attribute to the qss of QComboBox/QCheckBox, and the font color attribute color will take effect on QComboBox/QCheckBox.
QComboBox {
color: rgb(255, 0, 0);
padding: 0px 0px 0px 4px;
}
QCheckBox {
color: rgb(255, 0, 0);
padding: 0px 0px 0px 0px;
}
QCheckBox font color attribute color is the same as QComboBox.
2. Running results