How to refresh FolderListModel?
-
You mean when files are added in the folder, then the FolderListModel should automatically update the model?
Or manually refresh the FolderListModel?
-
I know this is an old thread but I searched for a long time to find an answer to this. The following worked for me, without this, when a file was added/deleted the list view was not updated properly (unless I exited and reopened the application).
@import QtQuick 1.1
import Qt.labs.folderlistmodel 1.0ListView {
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()
}
@
Source from:
http://stackoverflow.com/questions/11359854/update-listview-showin-in-tab-bar-layout-qml -
Looks like FolderListModel update the list automatically once new files are added or remove from path:(Qt5.7.1)
ListView { id:myListViewUSB anchors.fill: parent FolderListModel { id: folderModelUSB folder: "file:///mnt/usb" } model: folderModelUSB delegate: Text { text: fileName anchors.horizontalCenter: parent.horizontalCenter } }