如何使用 QML 获取存储在 .qrc Qt 资源文件中的文件列表?

how to get list of files stored in a .qrc Qt Resource file with QML?

如果想用 C++ 实现,可以这样做:

QDirIterator it(":", QDirIterator::Subdirectories);
while (it.hasNext()) {
    qDebug() << it.next();
}

但是,如果我想在 QML/Javascript 中做同样的事情,我该怎么做?

我会用 FolderListModel 来完成。在这里,我修改了找到 here 的示例,以显示资源 table.

中的所有内容
    ListView {
        width: 200; height: 400

        FolderListModel {
            id: folderModel
            folder: "qrc:/"
            nameFilters: ["*"]
        }

        Component {
            id: fileDelegate
            Text { text: fileName }
        }

        model: folderModel
        delegate: fileDelegate
    }