QTreeView remove decoration/expand button for all items

最后都变了- 提交于 2020-01-02 02:44:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!