如何改变Qt qListView图标选择高亮
在图标模式下使用 qlistview 时,我需要在选择图标时完全删除突出显示。 使用图标下的文本下方的代码不再突出显示,但在选择时我仍然在图标上显示蓝色
QString stylesheet = "";
stylesheet += "QListView::item:alternate {background-image: transparent; background-color: transparent;}";
stylesheet += "QListView::item:selected {background-image: transparent; background-color: transparent;padding: 0px;color: black;}";
stylesheet += "QListView::item:selected:active{background-image: transparent;background-color: transparent; color: black;}";
stylesheet += "QListView::item:selected:!active{background-image: transparent;background-color: transparent;color: black;}";
setStyleSheet(stylesheet);
有人知道如何更改图标上的选定颜色而不必子类化 QStandardItem 吗?
When using qlistview in icon mode I need to completely remove the hilighting when a icon is selected.
Using the code below the text under the icon is no longer highlighted but I still get blue color over the icon when selected
QString stylesheet = "";
stylesheet += "QListView::item:alternate {background-image: transparent; background-color: transparent;}";
stylesheet += "QListView::item:selected {background-image: transparent; background-color: transparent;padding: 0px;color: black;}";
stylesheet += "QListView::item:selected:active{background-image: transparent;background-color: transparent; color: black;}";
stylesheet += "QListView::item:selected:!active{background-image: transparent;background-color: transparent;color: black;}";
setStyleSheet(stylesheet);
does anyone know how to change the selected color over the icon without having to subclass QStandardItem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于带有 QStandardItem 的 QListView ,可以做你想做的事情。只需创建一个图标并为正常状态和选定状态添加相同的像素图。然后在item中setIcon
For a QListView with QStandardItem's it's possible to do what you want. Simply create an icon an add the same pixmap for both normal and selected states. Then setIcon in the item
找到了我自己的答案。在不使用委托的情况下无法删除 QListview 中的部分颜色覆盖,但在切换到使用 QListWidget 后,我可以通过设置选定的图标图像来禁用选择覆盖
Found my own answer. could not remove the section color overlay in QListview without using delegate but after switching to use QListWidget I could disable the selection overlay by setting a selected icon image