Reputation: 329
I would like to know how to hide a specific folder in a treeView with QFileSystemModel
.
I know that we can filter folders to show only some files using setFilter
but I don't know how to filter a folder.
I want to display folders except one. I know the name of this folder so I can choose it by the name.
Does anyone know how to hide/remove this folder from the list please?
Upvotes: 1
Views: 1458
Reputation: 98495
The filters can use wildcards, but those wildcards are optional. You're free to use the filters to filter out a non-wildcard name.
QStringList filters;
filters << "*.badext" << "foldername";
model->setNameFilters(filters);
If you want tighter control over it - for example, to only filter out folder with a given name, and not a file with a given name, then you need to implement a QSortFilterProxyModel
.
Upvotes: 3