FolderListModel
-
am trying to use FolderListModel in windows , accordig to the example in http://doc.qt.nokia.com/4.7-snapshot/qml-folderlistmodel.html#
@ListView
{
anchors.fill: parent
FolderListModel
{
id: foldermodel
folder: "C:/Qt/Projects/"
showDirs: true
showDotAndDotDot: true
nameFilters: ["*.qml"]
sortField : "Name"
}
Component
{
id: filedelegate
Text { text: fileName }
}
model: foldermodel
delegate: filedelegate
} @i want to show all the files/directories under the base directory, in a recursive way. does any one have an idea how to do that?
-
You should remove:
@nameFilters: ["*.qml"] @ -
and how can you make it a tree of files from the base folder?
in other words, when you have a directory you can click on it and get all the included files and directories...
when i write this code:
@ListView
{
anchors.fill: parent
FolderListModel
{
id: foldermodel
folder: "C:/Qt/Projects"
}
Component
{
id: filedelegateRectangle { width: 100;height: 20 Text { text: fileName} MouseArea { anchors.fill: parent onClicked: { foldermodel.folder = filePath; } } } } model: foldermodel delegate: filedelegate }@
it change all the base folder of the tree, and i want to add item to the tree.
-
Take a look at: "this thread":http://developer.qt.nokia.com/forums/viewthread/5462
In your delegate you shoud check if element is folder or file and if it is folder you should create a new ListView with FolderListModel filePath.
-
how can i use this? i didn't understand the example, because the model should be FolderListModel , and this example use the regular ListModel
-
Try this:
Create two delegates in two files: FileDelegate.qml and FolderDelegate.qml
In FileDelegate.qml you will have only @Text { text: fileName } @
and in FolderDelegate you will have ListView with FolderListModel pointing to fileName.ListView delegate should be Loader that loads FileDelegate.qml or FolderDelegate.qml after checking if current element is file or folder.
And the main QMl file can be FolderDelegate pointing to "C:/Qt/Projects".
I`ll try to write an example, when I go home, but I think this will work :)
-
what do you meen bq. in FolderDelegate you will have ListView with FolderListModel pointing to fileName.?
what should be in FolderDelegate.qml? and how can i pass the folder to this file?
-
now it does work, but it's realy slowly, ithink it's because the recursion. do you have an idea how to solve this?
-
I think the problem is that you`ve got a lot of ListViews in ListViews. May be you can optimize something. For example:
- Subdirectory should display it
s content only when it
s name is clicked - When some subdirectory is not on focus ( you are working somewhere else ) you can close it.
This should reduce number of ListViews :)
- Subdirectory should display it
-
Hi,
Just a side remark I am also using FolderListModel
but I am unsure it is supported by nokia ovi store for symbian platformYou have been warned
http://qt-project.org/doc/qt-4.8/qml-folderlistmodel.html
Note: This type is made available by importing the Qt.labs.folderlistmodel module. Elements in the Qt.labs module are not guaranteed to remain compatible in future versions.
More details :