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 refresh FolderListModel?
Forum Updated to NodeBB v4.3 + New Features

How to refresh FolderListModel?

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 4 Posters 4.8k 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.
  • M Offline
    M Offline
    mismail
    wrote on last edited by
    #1

    hello everybody,

    Is there any way to refresh the FolderListModel so the view is able to display the new files added.

    Thank you

    1 Reply Last reply
    0
    • M Offline
      M Offline
      minimoog77
      wrote on last edited by
      #2

      You mean when files are added in the folder, then the FolderListModel should automatically update the model?

      Or manually refresh the FolderListModel?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mismail
        wrote on last edited by
        #3

        there is no deference I need the view to feel that something is added, whether this done manually or automatically.

        1 Reply Last reply
        0
        • K Offline
          K Offline
          k1mray2000
          wrote on last edited by
          #4

          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.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()
          

          }
          @
          Source from:
          http://stackoverflow.com/questions/11359854/update-listview-showin-in-tab-bar-layout-qml

          1 Reply Last reply
          1
          • michaelLM Offline
            michaelLM Offline
            michaelL
            wrote on last edited by
            #5

            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
                        }
                    }
            
            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