如何更改Qt qListView图标选择突出显示 [英] how to change Qt qListView Icon selection highlight

查看:128
本文介绍了如何更改Qt qListView图标选择突出显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在图标模式下使用qlistview时,选择图标后,我需要完全消除阴影.使用图标下方文本下方的代码不再突出显示,但是选择后我仍然在图标上方显示蓝色

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);

有人知道如何在图标上更改所选颜色而不必继承QStandardItem吗?

does anyone know how to change the selected color over the icon without having to subclass QStandardItem?

推荐答案

对于具有QStandardItem的QListView,可以执行您想要的操作.只需创建一个图标,然后为正常状态和选定状态添加相同的像素图即可.然后在项目

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

QIcon icon;

icon.addPixmap(yourPixmap,QIcon::Normal);
icon.addPixmap(yourPixmap,QIcon::Selected);

qstandardItem.setIcon(icon);

这篇关于如何更改Qt qListView图标选择突出显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆