QT自定义控件重叠颜色异常
2016-07-27 12:17
459 查看
首先看错误效果
这是两个QListWidget的item
QListWidget 设置了alternatingRowColors(item 交替变换颜色)
item是我自定义的widget控件,上面放了一些QLabel,其中文本QLabel我使用QPalette设置为灰色,但始终显示黑色。
下面是修正效果图
原因:先看QT Assistant 对于alternatingRowColors属性的解释
If this property is true, the item background will be drawn usingQPalette::Base
andQPalette::AlternateBase; otherwise the background will be drawn using theQPalette::Base
color.
所以我认为item的QPalette也被改变,通过setBackgroundRole(QPalette::Text);即可是文本正确显示
这是两个QListWidget的item
QListWidget 设置了alternatingRowColors(item 交替变换颜色)
item是我自定义的widget控件,上面放了一些QLabel,其中文本QLabel我使用QPalette设置为灰色,但始终显示黑色。
下面是修正效果图
原因:先看QT Assistant 对于alternatingRowColors属性的解释
If this property is true, the item background will be drawn usingQPalette::Base
andQPalette::AlternateBase; otherwise the background will be drawn using theQPalette::Base
color.
所以我认为item的QPalette也被改变,通过setBackgroundRole(QPalette::Text);即可是文本正确显示
相关文章推荐
- QToolTip换行
- MQTT
- 从今天开始,从头开始学习Qt
- Qt5配置opencv注意事项
- Qt:多线程中断
- QT的一些注意点与方法积累
- QT 常见格式转换
- QT如何实现置顶窗口
- 安装qtceator后无法启动help插件 Qt编译错误:cannot find -lGL 解决办法
- Qt读写ini文件
- QT程序编译无错误,运行时出现访问地址冲突
- 发射的信号不能启动槽函数的几点原因(未完待续中。。。)
- QT实现类似QQ的截图功能
- Qt下载地址
- pyqt5表格qtablewidget
- MAC地址特殊规定--设置MAC地址时需要有非法MAC设置判断,否则会导致网卡无法启动
- pyqt5:标签显示文本框内容
- qt bck
- win8.1+vs2013下安装CGAL(含qt、boost、cmake)
- Qt在Windows下的三种编程环境搭建