如何防止图标突出显示?
我有一个列表小部件,其中包含带有图标的项目。选择该项目后,文本和图标都会突出显示。我的问题是,当图标突出显示时,它会变成全黑,因为我只使用两种颜色。有没有办法阻止图标被选择?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以向 QIcon 添加其他图像,具体取决于其状态:
另请参阅 QIcon::addFile()。
You can add additional images to the QIcon, depending on it's state:
See also the documentation of QIcon::addFile().
最好的解决方案是制作自己的 qstyle 来处理 listitem 子控件的背景绘制并将图标 qrect 绘制为白色
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
另一种可能性是重新实现 QListWidgetItem...因此,您可以更好地控制在选择和绘制过程中如何完成事情...
当然,这需要更多的工作...
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...