• 8517阅读
  • 4回复

【已解决】 怎么去掉QTreeView选中节点前面的灰色 [复制链接]

上一主题 下一主题
离线ppdayz
 

只看楼主 倒序阅读 楼主  发表于: 2011-03-29
【已解决】 怎么去掉QTreeView选中节点前面的灰色
我利用stylesheet 改变了treeWidget的外观,但是被选中的节点的前面的一段灰色的总是去不掉,如图,各位有什么办法,请指教下。代码是我的stylesheet。
  1. QTreeView {
  2.     font: bold 18px;
  3.     color:yellow;
  4.     show-decoration-selected: 1;
  5.     /*background-image: url(resource/background.png);*/
  6.     background-color:transparent;
  7.     border: 0px solid #eaeaea;
  8. }
  9. QTreeView::item {
  10.     border: 0px solid #d9d9d9;
  11.     border-top-color: transparent;
  12.     border-bottom-color: transparent;
  13. }
  14. QTreeView::item:hover {
  15.     border-image: url(:/light.png);
  16. }
  17. QTreeView::item:selected {
  18.     border: 1px solid #567dbc;
  19.     /*border-image: url(:/light.png);*/
  20.     background-image: url(resource/background.png);
  21. }
  22. QTreeView::item:selected:active{
  23.     background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);
  24.     /*background-color:  transparent;*/
  25.     background-image: url(resource/background.png);
  26. }
  27. QTreeView::item:selected:!active {
  28.     /*background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);*/
  29.     background-color:  transparent;
  30. }
  31. QTreeView::branch {
  32.     background: rgba(0, 0, 0, 0);
  33. }


[ 此帖被ppdayz在2011-03-30 15:52重新编辑 ]
离线ppdayz

只看该作者 1楼 发表于: 2011-03-29
给自己先顶一个
离线ppdayz

只看该作者 2楼 发表于: 2011-03-30
http://doc.qt.nokia.com/latest/stylesheet-reference.html#selection-background-color-prop
加个selection-background-color: transparent;就行


还是要多看看reference
[ 此帖被ppdayz在2011-03-30 15:55重新编辑 ]
离线cliffordl

只看该作者 3楼 发表于: 2014-12-17
你好,我按照你的步骤实现了一遍。前面的那部分,还是没去掉啊?
离线cliffordl

只看该作者 4楼 发表于: 2014-12-17
setStyleSheet("QTreeView {\
                                  font: bold 18px;\
                                color:yellow;\
            selection-background-color: transparent;\
            show-decoration-selected: 1;\
            background-color:transparent;}\
            QTreeView::item {\
                border: 0px solid green;\
                border-top-color: transparent;\
                border-bottom-color: transparent;}\
            QTreeView::item:selected {\
                border: 1px solid red;\
                /*background-image: url(:/ui/statusBar/status_bg.png);*/\
            QTreeView::branch {\
                background: rgba(125, 125, 125, 50);}\
            QTreeView::item:selected:active{\
                background:black;}\
            QTreeView::item:selected:!active {\
                background-color:  transparent;}\
            QTreeView::branch {\
                background: rgba(0, 125, 0, 50);}\
            ");
快速回复
限100 字节
 
上一个 下一个