Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyQt: removing unnecessary columns

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.

like image 505
gruszczy Avatar asked Dec 10 '10 21:12

gruszczy


2 Answers

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

like image 79
Harald Scheirich Avatar answered Oct 23 '22 12:10

Harald Scheirich


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)
like image 30
zeFree Avatar answered Oct 23 '22 12:10

zeFree