问题
I am trying to use FolderListModel, according to this example
like this:
ListView
{
anchors.fill: parent
FolderListModel
{
id: foldermodel
folder: "C:/Qt/Projects/"
showDirs: true
showDotAndDotDot: true
nameFilters: ["*"]
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?
回答1:
It seems that you have an invalid URL in the folder property. Documentation for FolderListModel element describes 'folder' property as:
The folder property holds a URL for the folder that the model is currently providing. The value is a URL expressed as a string, and must be a file: or qrc: URL, or a relative URL. By default, the value is an invalid URL.
This means that the folder property must be in format folder: "file:///[Directory path]"
. For instance, try changing your folder property in this case to: folder: "file:///C:/Qt/Projects/"
and see if that works.
回答2:
I think this cant be done without crawling the fs , this would requiere to create a list model and copy the tree inside ...
btw beware of cycles , filter . and .. out
-- http://rzr.online.fr/q/qml
来源:https://stackoverflow.com/questions/6563243/qml-folderlistmodel