QComboBox AbstractItemView::item
Your style sheet seemed correct, so I tried it. It seems the problem is similar to this one on Qt centre:
QCompleter
sets a customQAbstractItemDelegate
on its model and unfortunately this custom item delegate does not inheritQStyledItemDelegate
but simplyQItemDelegate
(and then overrides thepaint
method to show the selected state).
If you replace the default delegate by a QStyledItemDelegate
, your style sheet should work:
QStyledItemDelegate* itemDelegate = new QStyledItemDelegate();
combo->setItemDelegate(itemDelegate);
Important: If you change the model, then that will reset the view's delegate, so the above method needs to be called after any call to setModel()
.