Unsolved How to filter folder in treeview
-
http://i.hizliresim.com/LgMq1a.png
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:
model->setRootPath(path-to-directory-you-want-to-display);
-
this is not problem. problem is all show folders.
I want to show I wanted folder -
-
@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 -
Perhaps try one of these forums: https://forum.qt.io/category/36/international
-
So you want to hide all the other folders?
Sounds a lot like:
https://forum.qt.io/topic/59973/how-do-i-limit-the-files-that-are-shown-in-qfiledialogAlso the file system model docs is a good place to look:
http://doc.qt.io/qt-5/qfilesystemmodel.htmlHope 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.