选择QListWidgetItem而不更改文本颜色 [英] Selected QListWidgetItem without changing text color

查看:2065
本文介绍了选择QListWidgetItem而不更改文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有qListWidget有一些项目有不同的文字颜色。我想更改所选项目的背景颜色,而不触摸文本的颜色。我尝试了styleSheet,但所有选定的项目具有相同的颜色。
可以选择项目而不改变文本的颜色。

I've got qListWidget with some items which have different text colors. I want to change background color of selected item without touching color of text. I tried with styleSheet but then all selected items has same colors. It is posible to select item without changing color of the text?

推荐答案

尝试使用 item-> setData(Qt :: BackgroundRole,QBrush(color));

这篇关于选择QListWidgetItem而不更改文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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