• 1394阅读
  • 2回复

QTableView 如何给各行添加属性 [复制链接]

上一主题 下一主题
离线winston_zbb
 

只看楼主 倒序阅读 楼主  发表于: 2021-03-16
我想实现QTableView 中不同行背景颜色不同,想到的方法是:通过给QTableView中不同行添加不同属性(setProperty),然后用Qss 实现背景颜色变化。请教下,qt可以实现给表格中的行添加属性(setProperty)么?
离线liudianwu

只看该作者 1楼 发表于: 2021-03-16
好像不行,不能单独设置,你只能动态识别点了哪一行然后全局设置样式表
欢迎关注微信公众号:Qt实战/Qt入门和进阶(各种开源作品、经验整理、项目实战技巧,专注Qt/C++软件开发,视频监控、物联网、工业控制、嵌入式软件、国产化系统应用软件开发) QQ:517216493  WX:feiyangqingyun  QQ群:751439350
离线青空飞羽

只看该作者 2楼 发表于: 2021-03-17
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)
快速回复
限100 字节
 
上一个 下一个