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

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 2 Nov 2016, 18:16 last edited by A Former User 11 Feb 2016, 19:05
    #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?

    C 1 Reply Last reply 2 Nov 2016, 18:25
    0
    • L literA2
      2 Nov 2016, 18:16

      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?

      C Offline
      C Offline
      CharlieG
      wrote on 2 Nov 2016, 18:25 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 3 Nov 2016, 09:32
      0
      • C CharlieG
        2 Nov 2016, 18:25

        @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 3 Nov 2016, 09:32 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 4 Nov 2016, 08:48 last edited by
          #4

          I resolved this issue by using folder instead of rootFolder.

          Thanks.

          1 Reply Last reply
          0

          1/4

          2 Nov 2016, 18:16

          • Login

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