Design patterns qml FolderListModel
根据这一点,我正在尝试使用FolderListModel 像这样:Design patterns qml FolderListModel,design-patterns,model,delegates,qt4,qml,Design Patterns,Model,Delegates,Qt4,Qml,根据这一点,我正在尝试使用FolderListModel 像这样: ListView { anchors.fill: parent FolderListModel { id: foldermodel folder: "C:/Qt/Projects/" showDirs: true showDotAndDotDot: true nameFilters: ["*"] sortFi
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
}
我想以递归的方式显示基本目录下的所有文件/目录。
有人知道怎么做吗?文件夹属性中似乎有一个无效的URL。元素将“文件夹”属性描述为: folder属性保存模型当前提供的文件夹的URL。该值是以字符串表示的URL,必须是file:或qrc:URL或相对URL。默认情况下,该值是无效的URL
这意味着文件夹属性的格式必须为
文件夹:“文件:///[目录路径]”
。例如,在本例中,请尝试将文件夹属性更改为:folder:file:///C:/Qt/Projects/“
然后看看这是否有效。我认为如果不对fs进行爬网,这将无法完成,这将需要创建一个列表模型并复制其中的树
顺便说一句,注意循环,过滤器。和。。出去
--