查看完整版本: [-- QTableview 添加qss 然后再添加QItemDelegate那栏没有QSS效果 --]

QTCN开发网 -> Qt基础编程 -> QTableview 添加qss 然后再添加QItemDelegate那栏没有QSS效果 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

fkeujjpdc 2016-12-28 08:39

QTableview 添加qss 然后再添加QItemDelegate那栏没有QSS效果

QTableview 添加qss 然后再添加QItemDelegate那栏没有QSS效果,我用的是Qt5.7 + VS2013  + WIN7
[attachment=16277]
大家看图片效果,值那一栏我添加了ui->treeView->setItemDelegateForColumn
我的Qss是这样的
QTreeView {    alternate-background-color: yellow;}
QTreeView {    show-decoration-selected: 1;}
QTreeView::item {    border: 1px solid #d9d9d9;    border-left-color: transparent;    border-top-color: transparent;}QTreeView::branch {    border-bottom: 1px solid #d9d9d9;    background: palette(base);}
/* 鼠标在QTreeView上面移动时的效果 */QTreeView::item:hover {    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);    border: 1px solid #bfcde4;}
QTreeView::item:selected {    border: 1px solid #567dbc;}/* 节点被选中激活时的效果 */QTreeView::item:selected:active{    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);}
QTreeView::item:selected:!active {    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);}
为什么唯独QItemDelegate那一栏不生效,我只要去掉setItemDelegateForColumn又正常了,但是我就用不了QItemDelegate过滤功能了

fkeujjpdc 2016-12-29 15:08
自己顶一下,有没有哪位帮我看看,这个问题应该很多人都会遇到啊。
QTreeView 设置QItemDelegate后,QItemDelegate那栏qss失效

tyche116 2017-01-07 15:02
你试试在委托那里写样式。      

fkeujjpdc 2017-01-09 15:30
谢谢你的回复,委托那里写样式什么意思,我qss直接全局加载的,能不能说的详细点。

lemonzll 2017-01-09 16:18
用QStyledItemDelegate试下,不要用QItemDelegate

fkeujjpdc 2017-01-09 16:53
十分感谢,按lemonzll问题解决了,上图表示感谢[attachment=16319]


查看完整版本: [-- QTableview 添加qss 然后再添加QItemDelegate那栏没有QSS效果 --] [-- top --]



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