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 set rootFolder in FolderListModel
Forum Update on Monday, May 27th 2025

How to set rootFolder in FolderListModel

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 1.7k Views
  • 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.
  • L Offline
    L Offline
    literA2
    wrote on last edited by A Former User
    #1

    In moving up directory i have this javascript:

    function dirUp() {
      if (parentFolder.toString() != "") {
        folder = parentFolder;
      }
    }
    

    I wanted to know what property to check to prevent it from moving up once it is currently in sanbox (ios).

    Based on the docs, setting the rootFolder prevents from moving up to parent directory, however i have problem setting the url. I tried setting the rootFolder with folder default value, but to no avail.

    Any advise?

    CharlieGC 1 Reply Last reply
    0
    • L literA2

      In moving up directory i have this javascript:

      function dirUp() {
        if (parentFolder.toString() != "") {
          folder = parentFolder;
        }
      }
      

      I wanted to know what property to check to prevent it from moving up once it is currently in sanbox (ios).

      Based on the docs, setting the rootFolder prevents from moving up to parent directory, however i have problem setting the url. I tried setting the rootFolder with folder default value, but to no avail.

      Any advise?

      CharlieGC Offline
      CharlieGC Offline
      CharlieG
      wrote on last edited by
      #2

      @literA2

      Hi,

      Here is a simple example :

      import QtQuick 2.7
      import QtQuick.Controls 2.0
      import QtQuick.Window 2.2
      import QtQuick.Layouts 1.3
      import Qt.labs.folderlistmodel 2.1
      
      Window {
          height: 300
          width: 500
          modality: Qt.ApplicationModal
      
          ColumnLayout {
              anchors.fill: parent
      
              ListView {
                  width: 400; height: 200
      
                  FolderListModel {
                      id: folderModel
                      showDirs: true
                      showFiles: false
                      //nameFilters: ["*.qml"]
                  }
      
                  Component {
                      id: fileDelegate
                      Text { text: fileName }
                  }
      
                  model: folderModel
                  delegate: fileDelegate
              }
      
              Button {
                  text: qsTr("Parent")
                  //Layout.fillWidth: parent
                  onClicked: folderModel.folder = folderModel.parentFolder
              }
          }
      
      }
      ``
      L 1 Reply Last reply
      0
      • CharlieGC CharlieG

        @literA2

        Hi,

        Here is a simple example :

        import QtQuick 2.7
        import QtQuick.Controls 2.0
        import QtQuick.Window 2.2
        import QtQuick.Layouts 1.3
        import Qt.labs.folderlistmodel 2.1
        
        Window {
            height: 300
            width: 500
            modality: Qt.ApplicationModal
        
            ColumnLayout {
                anchors.fill: parent
        
                ListView {
                    width: 400; height: 200
        
                    FolderListModel {
                        id: folderModel
                        showDirs: true
                        showFiles: false
                        //nameFilters: ["*.qml"]
                    }
        
                    Component {
                        id: fileDelegate
                        Text { text: fileName }
                    }
        
                    model: folderModel
                    delegate: fileDelegate
                }
        
                Button {
                    text: qsTr("Parent")
                    //Layout.fillWidth: parent
                    onClicked: folderModel.folder = folderModel.parentFolder
                }
            }
        
        }
        ``
        L Offline
        L Offline
        literA2
        wrote on last edited by
        #3

        @CharlieG Thanks for the reply, my FolderListModel is already working, I just want to restrict from moving up once in sanbox.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          literA2
          wrote on last edited by
          #4

          I resolved this issue by using folder instead of rootFolder.

          Thanks.

          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