I would like to change the foreground color of cell widgets in a QTableWidget
. The hierarchy is the following:
QTableWidget
> QTableWidgetItem[]
>> QLabel
>> QLineEdit
>> QLineEdit
>> QLineEdit
>> QLineEdit
That is, five columns and N
rows in a list view. I want the font color of all sub-items to change when a row is selected/highlighted. I am trying to obtain this using QStyleSheet
.
Attempts
1) The following does not work, because it changes the color regardless of the selection state:
QTableWidget::item:selected QLabel,
QTableWidget::item:selected QLineEdit {
color: white;
}
2) The following does not work, because QLabel
/QLineEdit
does not respond to selection-color
:
QTableWidget::item:selected QLabel,
QTableWidget::item:selected QLineEdit {
color: #666;
selection-color: white;
}