QTreeView删除所有项目的装饰/展开按钮

时间:2013-04-15 15:24:24

标签: qt qtreeview

我希望我的QTreeView始终展开所有项目。在这种情况下,所有展开按钮/装饰都是不必要的,我想摆脱它们。如何删除所有这些? setRootIsDecorated只会删除第一级的按钮...

2 个答案:

答案 0 :(得分:17)

这是我过去为这个问题所做的,它有点像黑客但它的效果非常好。在这种情况下,none.png不存在。

treeView->setStyleSheet( "QTreeView::branch {  border-image: url(none.png); }" );

答案 1 :(得分:4)

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.