Important: Please read the Qt Code of Conduct -

Put a color to some items of a ComboBox and keep it for the selected item

  • Hi,
    I have a combobox with a list of items. Some items need to have a specific text color related to an internal property of the associated object. To do this, I found on Internet that I have to do:
    @comboBox->setItemItem(pos, color, Qt::ForegroundRole);@

    This works well unless for the selected item. This one is always displayed in black. This combobox has not (for the moment) associated stylesheet. Hence it is really the basic display.

    So, how can I force it to keep the text color I set even when the item is selected?

Log in to reply