查看完整版本: [-- QTableView 如何给各行添加属性 --]

QTCN开发网 -> Qt基础编程 -> QTableView 如何给各行添加属性 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

winston_zbb 2021-03-16 15:42

QTableView 如何给各行添加属性

我想实现QTableView 中不同行背景颜色不同,想到的方法是:通过给QTableView中不同行添加不同属性(setProperty),然后用Qss 实现背景颜色变化。请教下,qt可以实现给表格中的行添加属性(setProperty)么?

liudianwu 2021-03-16 16:24
好像不行,不能单独设置,你只能动态识别点了哪一行然后全局设置样式表

青空飞羽 2021-03-17 09:40
alternatingRowColors : bool
This property holds whether to draw the background using alternating colors
If this property is true, the item background will be drawn using QPalette::Base and QPalette::AlternateBase; otherwise the background will be drawn using the QPalette::Base color.
By default, this property is false.
Access functions:

bool
alternatingRowColors() const
void
setAlternatingRowColors(bool enable)


查看完整版本: [-- QTableView 如何给各行添加属性 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled