Qt5.9中利用QSS更改QTreeView的展開節點箭頭小圖示用法

三公子Tjq發表於2018-07-10

1.1要更改QTreeView的展開節點箭頭小圖示,用QSS主要用如下語句:

"QTreeView::branch:open:has-children:!has-siblings,"
"QTreeView::branch:open:has-children:has-siblings {image: url(:res/recoverydata/icon/icon_list_2.png);}"
"QTreeView::branch:has-children:!has-siblings:closed,"
"QTreeView::branch:closed:has-children:has-siblings {image: url(:res/recoverydata/icon/icon_list_1.png);}"
"QTreeView::item:hover {background-color:rgb(8,52,127);}"


1.2具體的用法如下所示:

recoveryTreeView->setStyleSheet("QTreeView{background-color: transparent;color:white;font: bold 14px;outline:none;}"
                                    "QTreeView::branch:open:has-children:!has-siblings,"
                                    "QTreeView::branch:open:has-children:has-siblings {image: url(:res/recoverydata/icon/icon_list_2.png);}"
                                    "QTreeView::branch:has-children:!has-siblings:closed,"
                                    "QTreeView::branch:closed:has-children:has-siblings {image: url(:res/recoverydata/icon/icon_list_1.png);}"
                                    "QTreeView::item:hover {background-color:rgb(8,52,127);}"
                                    "QTreeView::item:selected {background-color:rgb(8,52,127);border:1px solid #08347F;}");


1.3效果如下所示:



參考內容:


相關文章