Depending on some dynamic property, I'd like to set the font style in the top-item of a QComboBox to italic, but keep the appearance of the items in the corresponding popup (QListView).
I tried it with the following qss:
font-style: normal;
/* background-color: rgb(255, 255, 127);*/
}
font-style: italic;
/* background-color: rgb(85, 0, 255);*/
}
QComboBox#librarySettingsBox QListView {
font-style: normal;
/* background-color: rgb(255, 255, 127);*/
}
QComboBox[dirty="true"] {
font-style: italic;
/* background-color: rgb(85, 0, 255);*/
}
To copy to clipboard, switch view to plain text mode
In my C++ code, I call update on the widget after setting the property like this:
ui->librarySettingsBox->setProperty("dirty", dirty);
ui->librarySettingsBox->style()->unpolish(ui->librarySettingsBox);
ui->librarySettingsBox->style()->polish(ui->librarySettingsBox);
ui->librarySettingsBox->update();
ui->librarySettingsBox->setProperty("dirty", dirty);
ui->librarySettingsBox->style()->unpolish(ui->librarySettingsBox);
ui->librarySettingsBox->style()->polish(ui->librarySettingsBox);
ui->librarySettingsBox->update();
To copy to clipboard, switch view to plain text mode
The "font-style: normal" setting is supposed to override the italic setting in the QListView, as it has a higher priority due to the id-tag contained. This can also be confirmed by uncommenting the "background-color" tags. However, the font-style does not seem to have any effect on the QListView. Why is it so and how can I fix it?
Bookmarks