QComboBox highlighting
-
Hi!
I'm having problems using QComboBox (Qt.4.6).
Each item has a (colored) icon and text. This works fine. However, when I highlight an item by moving the mouse over it, highlight color gets applied also to the icon in the list. When an icon is yellow it gets highlighted via a blue transparent layer to green which is confusing because we also have green icons in the list. I would like to disable higlighting of the icon portion of the dropdown. Is that possible?
//Björn
-
Yes but it might need a bit of messing around.
That's just a listview you can access viacomboBox->view()
you have to set a delegate to it to get what you want.On top of my head I'd subclass
QStyledItemDelegate
, reimplementpaint
copying it from the original and just add:opt.text.clear(); opt.state &= ~QStyle::State_Selected; style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget);
at the end. This might mess up if you also have checkboxes but I assume it's not the case