PyQt: removing unnecessary columns

冷暖自知 提交于 2019-12-10 03:32:15

问题


I am using QTreeView with QFileSystemModel. It displays columns like Size, Type, Modification Date, which I don't need. How can I remove them from the view? I can't find any removeColumn in model or in view.


回答1:


Get the QHeaderView of your TreeView by calling header() on it, the headerview knows about the columns and can hide them via hideSection




回答2:


I believe, this post is a duplicate of:
How can I remove columns from a QTreeView (using QDirModel)?

The only difference is that here we are using QFileSystemModel instead of QDirModel - which makes no difference since the columns needs to be hidden in the view.

So I believe pointing to the right solution is the best thing to do.

QTreeView::setColumnHidden(int column, bool hide)


来源:https://stackoverflow.com/questions/4413595/pyqt-removing-unnecessary-columns

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