隐藏左側的小箭頭
treeView.setRootIsDecorated(False)
或者
treeView.setStyleSheet( "QTreeView::branch {image:none;}" )
設定item不同狀态下顯示背景色的代碼,設定方法同上: 源碼中設定:
treeWidget->setStyleSheet( "QTreeView::item:hover{background-color:rgb(0,255,0,50)}"
"QTreeView::item:selected{background-color:rgb(255,0,0,100)}" );
在樣式設定界面,添加如下兩句:
QTreeView::item:hover{background-color:rgb(0,255,0,50)}
QTreeView::item:selected{background-color:rgb(255,0,0,100)}