How to filter folder in treeview
I want to show just Bring2d folder on treeview
The docs are a good place to start: QTreeView Class
QFileSystemModel *model = new QFileSystemModel; model->setRootPath(QDir::currentPath()); QTreeView *tree = new QTreeView(splitter); tree->setModel(model);
@TOMATO_QT please give me example.
my English is not enough :(
This the example:
this is not problem. problem is all show folders.
I want to show I wanted folder
...show some effort?
@TOMATO_QT I could not tell .
It will only appear in the root directory of your home folder
so There will not be other folders . (e.g users - bin- etc.) just home folder
So you want to hide all the other folders?
Also the file system model docs is a good place to look:
Hope that helps!
Unfortunately QFileSystemModel does not have a built-in way to filter out directories, only files. The reason is performance related to how file systems work.
To do directory filtering you could subclass a QSortFilterProxyModel and implement its filterAcceptsRow() method to pass through only the directory you want.