0

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?

2 Answers 2

0

Try to use item->setData(Qt::BackgroundRole, QBrush(color));.

1
  • I tried, but effect is the same. Selection changes color of the text in item. Aug 4, 2013 at 8:54
0

If you're using the Qt Designer, go to the properties (property editor) of QListWidget you want this behavior for. Go to 'palette', and click 'Change Palette'. Then change the 'Highlighted Text' color to same color that you're using for non-highlighted text.

When selecting an item, the item's text color is still changing, but it will be changing to the same color, so it will appear as if it's not changing.

I attached a photo for your convenience.

Where you can change 'Highlighted Text'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.