qml FolderListModel [英] qml FolderListModel

查看:519
本文介绍了qml FolderListModel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据这个示例,我试图使用FolderListModel a>



像这样:

  ListView 
{
anchors.fill:parent
FolderListModel
{
id:foldermodel
文件夹:C:/ Qt / Projects /
showDirs:true
showDotAndDotDot:true
nameFilters:[*]
sortField:Name
}
组件{
id:filedelegate
文本{text :fileName}
}
模型:foldermodel
委托:filedelegate
}

我想以递归的方式显示基本目录下的所有文件/目录。
是否有任何想法如何做?

解决方案

似乎您在文件夹属性。 FolderListModel的文档元素将文件夹属性描述为:


该文件夹属性保存模型当前提供的文件夹的URL。该值是以字符串表示的URL,并且必须是文件:或qrc:URL或相对URL。默认情况下,该值是无效的URL。


这意味着文件夹属性必须格式为 :file:/// [Directory path]。例如,在这种情况下,请尝试将文件夹属性更改为:文件夹:file:/// C:/ Qt / Projects /,看看是否有效。 p>

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?

解决方案

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.

这篇关于qml FolderListModel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆