问题
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...
回答1:
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); }" );
回答2:
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.
来源:https://stackoverflow.com/questions/16018974/qtreeview-remove-decoration-expand-button-for-all-items