PyQt:删除 QTreeView 列

发布于 2024-10-07 02:04:45 字数 126 浏览 0 评论 0原文

我将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒解孤独 2024-10-14 02:04:46

通过调用 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 via hideSection.

情归归情 2024-10-14 02:04:46

我相信,这篇文章是以下内容的重复:
如何从 QTreeView 中删除列(使用 QDirModel)?

唯一的区别是这里我们使用 QFileSystemModel 而不是 QDirModel - 这没有什么区别,因为列需要隐藏在视图中。

所以我相信指出正确的解决方案是最好的做法。

QTreeView::setColumnHidden(int column, bool hide)

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)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文