[Qt Development Notes] Solutions for QComboBox/QCheckBox setting qss style sheet font color color attribute on Linux system (Ubuntu14.04) does not take effect or QComboBox only takes effect for the drop-down list

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);
}

insert image description here
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).
insert image description here
But after expanding the QComboBox, it is found that the font color of the item in the drop-down box changes.
insert image description here

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;
}

insert image description here
QCheckBox font color attribute color is the same as QComboBox.

2. Running results
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/qq_37354286/article/details/103201494
Recommended