开发者

How to prevent an icon being highlighted?

I have a listwidget with items which have icons. When the item is selected both the text and the icon are highlighted. My problem is 开发者_开发技巧that when the icon is highlighted it just goes entirely black because I'm using only two colours. Is there a way to prevent the icon from being selected?


You can add additional images to the QIcon, depending on it's state:

 QIcon icon(...);
 icon.addFile("selected.png", size, QIcon::Selected);

See also the documentation of QIcon::addFile().


Best solution was to make your own qstyle which handled the painting of the backgrounds of listitem sub controls and draw the icons qrect as white


Another possibility would be to reimplement QListWidgetItem... You could therefore have a bigger control on how things gets done during the process of selection and painting...

Of course, it's a lot more work...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜