Directory Listing with QML

  • I'm trying to list the content of a directory (of picture files) and store it in an array in order to display the pictures in a slideshow using QML.

    I've tried to use ListView for that:

    @import QtQuick 1.0
    import Qt.labs.folderlistmodel 1.0

    Rectangle {
    ListView {
    width: 0; height: 0

         FolderListModel {
             id: folderModel
             folder: "file:///C:/QtProj/PigitalSignage/qml/PigitalSignage/video"
             nameFilters: ["*.*"]
         Component {
             id: fileDelegate
             Text {
                 text: fileName
                 onTextChanged: {
                     console.debug("Filename:-" + fileName + "-")
         model: folderModel
         delegate: fileDelegate


    But this is not ideal since it will only show files that are displayed in the window, I could give a large number of height but that does seem too good.

    I could also not find a way to create a (changeable) array with QML. I tried variant, but it seems read-only.

    Is there a way to do that with QML, or do I need to work something out in C++?

  • As i understand you need a scrollable list view am i right?

  • Sorry for not being clear. I don't need to show the file list. I would just need to display each picture for X seconds.

  • This may be totally off-base but you could try something like this:

    onCompleted: // start timer

    onTimerElapsed: // load another one, ie: change source

    I haven't tried it, but it seems like a good idea, =D, hope this helps

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.