qml FolderListModel

♀尐吖头ヾ 提交于 2020-01-01 09:18:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!