I want to have my QTreeView
always expanded all of the items. In that case, all expand button / decoration are unnecessary and I want get rid of them. How can I delete all of them? setRootIsDecorated
will only delete that buttons on first level...
Asked
Active
Viewed 6,974 times
12

GwynBleidD
- 20,081
- 5
- 46
- 77
2 Answers
20
This is what I've done in the past for this problem, it's a bit of a hack but it's worked pretty well. In this case none.png
doesn't exist.
treeView->setStyleSheet( "QTreeView::branch { border-image: url(none.png); }" );

Chris
- 17,119
- 5
- 57
- 60
-
1please tell me where I can look up the names of these style sheets, like how did you find out that this decoration thing is called QTreeView::branch? I want to find out what other things' names are, too. – Pavel Nov 01 '16 at 08:53
-
@Pavel Late but for other readers: https://doc.qt.io/qt-5/stylesheet-reference.html – Tilman Vogel Jan 05 '22 at 11:35
8
See https://forum.qt.io/topic/4767/how-to-get-rid-of-expande-collapse-qtreewidgetitem-indicator
This got rid of the top level ones for me: self.setRootIsDecorated(False)
.
I didn't try the item polocy mentioned so I'm not sure this answer can be considered complete. If anyone can verify, feel free to edit this with the confirmation. Until then consider this answer an info-share.

Rafe
- 1,937
- 22
- 31