Ok I came back to this problem and found the problem & solution! So I thought I would share because I came across other people posting similar problems but never anybody posting a solution.
QCompleter sets a custom QAbstractItemDelegate on it's model and unfortunately this custom item delegate does not inherit QStyledItemDelegate but simply QItemDelegate (and then overrides the paintmethod to show the selected state).
So in order to use the stylesheet ::item subcontrol with QCompleter you need to do something like this
mCompleterItemDelegate = new QStyledItemDelegate(this);
...
mCompleter.setModel(someitemmodel);
mCompleter.popup()->setItemDelegate(mCompleterItemDelegate); //Must be set after every time the model is set
mCompleterItemDelegate = new QStyledItemDelegate(this);
...
mCompleter.setModel(someitemmodel);
mCompleter.popup()->setItemDelegate(mCompleterItemDelegate); //Must be set after every time the model is set
To copy to clipboard, switch view to plain text mode
Now the items in the QCompleter popup list can be styled via standard stylesheet syntax
margin: 2px;
}
background: orange;
}
QListView::item {
margin: 2px;
}
QListView::item:selected {
background: orange;
}
To copy to clipboard, switch view to plain text mode
Bookmarks