问题
I've got qListWidget with some items which have different text colors. I want to change background color of selected item without touching color of text. I tried with styleSheet but then all selected items has same colors. It is posible to select item without changing color of the text?
回答1:
Try to use item->setData(Qt::BackgroundRole, QBrush(color));
.
来源:https://stackoverflow.com/questions/18035707/selected-qlistwidgetitem-without-changing-text-color