[Interest] How to filter QFileSystemModel for use in QML
Curtis Mitch
mitch.curtis at theqtcompany.com
Thu Aug 13 14:27:08 CEST 2015
________________________________________
From: interest-bounces+mitch.curtis=theqtcompany.com at qt-project.org <interest-bounces+mitch.curtis=theqtcompany.com at qt-project.org> on behalf of Julius Bullinger <Julius.Bullinger at asctec.de>
Sent: Thursday, 13 August 2015 14:14
To: interest at qt-project.org
Subject: [Interest] How to filter QFileSystemModel for use in QML
Dear list,
I'm having problems using QFileSystemModel in QML.
Take the following example code:
// QQmlEngine* engine
QFileSystemModel* fsm = new QFileSystemModel(engine);
QModelIndex root = fsm->setRootPath("C:/Qt");
engine->rootContext()->setContextProperty("fileSystemModel", fsm);
Now, using for example a QTreeView, one could set the root by using
``QTreeWidget::setRootIndex(root)`` to filter everything above the root
level. But suppose I'd like to use the model in QML, e.g. in a TreeView
QML component which doesn't have a setRoot() property.
[snip]
I'm not sure about the rest of your question, but TreeView has a rootIndex property in 5.6:
https://codereview.qt-project.org/#/c/121991/
More information about the Interest
mailing list