PDA

View Full Version : QComboBox and Qt::BackgroundRole not working for selected item



mstegehu
31st October 2011, 14:11
When I add an item to a comboBox and set it's background the selected item will not get that color. If I drop down the combo box the background is colored.



m_itemComboBox->insertItem(0, file.fileName(), QVariant(file.absoluteFilePath()));
m_itemComboBox->setItemData(0, QString ("Non existing: %1").arg (file.absoluteFilePath()), Qt::ToolTipRole);
m_itemComboBox->setItemData(0, QBrush (QColor (255, 128, 64)), Qt::BackgroundRole); // Orange
m_itemComboBox->setCurrentIndex(0);


Does anyone know how to set the background of the activated item?

Regards,

Marcel