I cannot figure out how to change the text color of one particular item of a QComboBox. I was able to change the Background color of an item:
comboBox->setItemData(i, Qt::green, Qt::BackgroundRole);
(Qt::ForegroundRole
had no effect at all, Qt 4.6, Ubuntu 10.04)
and I was able to change the text color of all items with a stylesheet but I cannot figure out how to change the text color of one specified item.
Thanks for your Help!
It's almost like you propose, but you have to change the role to Qt::TextColorRole
.
comboBox->setItemData(0, QBrush(Qt::red), Qt::TextColorRole);