How to filter folder in treeview
-
wrote on 14 Dec 2015, 13:47 last edited by tako
http://i.hizliresim.com/LgMq1a.png
I want to show just Bring2d folder on treeview -
http://i.hizliresim.com/LgMq1a.png
I want to show just Bring2d folder on treeviewwrote on 14 Dec 2015, 18:38 last edited byThe 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);
-
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);
wrote on 14 Dec 2015, 18:53 last edited by@TOMATO_QT please give me example.
my English is not enough :( -
@TOMATO_QT please give me example.
my English is not enough :(wrote on 14 Dec 2015, 19:43 last edited byThis the example:
model->setRootPath(path-to-directory-you-want-to-display);
-
wrote on 14 Dec 2015, 20:05 last edited by
this is not problem. problem is all show folders.
I want to show I wanted folder -
wrote on 14 Dec 2015, 20:12 last edited by
-
wrote on 14 Dec 2015, 20:24 last edited by
@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 -
@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 folderwrote on 15 Dec 2015, 00:53 last edited byPerhaps try one of these forums: https://forum.qt.io/category/36/international
-
wrote on 15 Dec 2015, 07:31 last edited by
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.
1/10