Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to use FolderListModel?
Qt 6.11 is out! See what's new in the release blog

How to use FolderListModel?

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 608 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Enderson
    wrote on last edited by
    #1

    I create a QtQuick app and replace the main.qml with the code below. I try to show all files and dirs in my home path in a Mac OS X system. But nothing shows up. Could some one help to 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
        }
    }
    

    b.t.w.:
    Qt5.5
    .pro:

    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's code model
    QML_IMPORT_PATH =
    
    # Default rules for deployment.
    include(deployment.pri)
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved