更新列表视图中舒标签栏布局QML [英] Update Listview Showin in Tab Bar Layout QML

查看:255
本文介绍了更新列表视图中舒标签栏布局QML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个正常的标签栏和我显示从我的SD卡的特定目录列表视图的音乐文件。我希望当我下载目录中的一个新的文件要更新的列表。但因为我有显示标签栏列表中,QML中加载的开始。我怎么imlement呢?

I have created a normal tab bar and am showing music files in a listview from a specific directory from my sd card. I want the list to be updated when I download a new file in the directory. But since i have show the list in a tab bar, the qml is loaded in the beginning. How do I imlement this?

推荐答案

如果这是一个选择,我会抢QtQuick 2.0实现并使用它。它会自动反应到文件夹中的变化。

If it is an option for you, I'd grab the QtQuick 2.0 implementation and use that instead. It will automatically react to changes in the folder.

否则,你将别无选择,只能重新创建模型,例如

Otherwise, you'll have little choice but to recreate the model, e.g.

import QtQuick 1.1
import Qt.labs.folderlistmodel 1.0

ListView {
    id: view
    model: folderModel
    delegate: Text { text: fileName }

    property variant folderModel
    function updateModel() {
        var folder = ""
        if (folderModel) {
            folder = folderModel.folder
            folderModel.destroy()
        }
        folderModel = modelComponent.createObject(view, {"folder": folder})
    }

    Component {
        id: modelComponent
        FolderListModel {}
    }

    Component.onCompleted: updateModel()
}

丑陋,但它的作品。

Ugly, but it works.

这篇关于更新列表视图中舒标签栏布局QML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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