PyQt:删除 QTreeView 列
我将 QTreeView 与 QFileSystemModel 一起使用。它显示“大小”、“类型”、“修改日期”等我不需要的列。我怎样才能将它们从视图中删除?我在模型或视图中找不到任何 removeColumn
。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(2)
通过调用 header 获取 TreeView 的
QHeaderView
() 上, headerview 了解这些列,并可以通过隐藏部分
。Get the
QHeaderView
of your TreeView by calling header() on it, the headerview knows about the columns and can hide them viahideSection
.我相信,这篇文章是以下内容的重复:
如何从 QTreeView 中删除列(使用 QDirModel)?
唯一的区别是这里我们使用 QFileSystemModel 而不是 QDirModel - 这没有什么区别,因为列需要隐藏在视图中。
所以我相信指出正确的解决方案是最好的做法。
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.