views:

82

answers:

2

I have a QListWidget containing items which have icons and when the items are selected the icon is just highlighted out. Is there a way to prevent this? I can't use stylesheets because it's for an embedded application and including them takes up too much space. thanks

+1  A: 

Hey,

I suppose when you say "Highlithed out", you mean that the icon colors don't render well when the line is selected, and therefore, you can't see properly the icon...

Maybe you could consider using a different icon when the item is selected. It's possible to do so by specifing a mode to your icon.

Example :

QIcon MyIcon(":/images/foo");
MyIcon.addFile(":/images/bar", QSize(...), QIcon::Selected);

You can easily make a try in QtDesigner and see the results...

Hope it helps a bit !

Andy M
thanks but I forgot to mention I was using a black and white screen, so if the icon is highlighted at all the entire thing is just black. I need a way to prevent the icon from being highlighted.
Mark
Yeah, but it's the same process, by specifying your icon the way I proposed, you just specify the same icon for all the line status (unselected, selected, etc...)... Doesn't it suit your needs ?
Andy M
A: 

Certainly, drawing on a black-and-white screen presents its challenges.

It sounds like you just want to change the appearance of the interface, not any functionality. If this is the case, a QItemDelegate-derived class (or QStyledItemDelegate) is almost certainly what you want. In particular, the drawDecoration function looks like it is used to draw an icon, and the style options should include whether it is selected. The simplest fix would be to override that function, set the selected flag in the options to false, then pass it up to the parent's function.

Caleb Huitt - cjhuitt