Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide some columns in a QTreeView? [duplicate]

I have a QTreeView model, that model has four columns as the following (Name, Size, Type, Data Modified).

I want is to remove the (Size, Type, Data Modified) columns, and leave only the column named Name.

QFileSystemModel *sysModel = new QFileSystemModel;
sysModel->setRootPath("");
sysModel->setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
ui->treeView->setModel(sysModel);

I want to know, What function is responsible for that?

like image 225
Lion King Avatar asked Oct 31 '14 13:10

Lion King


1 Answers

QTreeView::setColumnHidden(int column, bool hide) does the trick.

You can also use QTreeView::hideColumn(int column).

like image 137
Andrea Avatar answered Oct 13 '22 08:10

Andrea