How to use FolderListModel
I am creating a QtQuick application and replacing main.qml with the code below. I am trying to show all files and directories in my home path on Mac OS X system. But nothing appears. Can anyone help figure out what I did wrong? Thanks in advance.
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import Qt.labs.folderlistmodel 2.1
ApplicationWindow {
visible: true
title: "Test"
width: 200
height: 400
ListView {
anchors.fill: parent
FolderListModel {
id: folderModel
showDirs: true
showDirsFirst: true
rootFolder: "file:///Users/enderson"
nameFilters: ["*.*"]
}
Component {
id: fileDelegate
Text { text: fileName }
}
model: folderModel
delegate: fileDelegate
}
}
btw: Qt5.5 and .pro file:
TEMPLATE = app
QT += qml quick widgets
SOURCES += main.cpp \
UiBridge.cpp
RESOURCES += qml.qrc
LIBS += -framework CoreFoundation -framework Foundation
# Additional import path used to resolve QML modules in Qt Creator code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)
+3
source to share