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. FolderListModel

FolderListModel

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 3 Posters 8.5k 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.
  • G Offline
    G Offline
    goli
    wrote on last edited by
    #1

    am trying to use FolderListModel in windows , accordig to the example in http://doc.qt.nokia.com/4.7-snapshot/qml-folderlistmodel.html#

    @ListView
    {
    anchors.fill: parent
    FolderListModel
    {
    id: foldermodel
    folder: "C:/Qt/Projects/"
    showDirs: true
    showDotAndDotDot: true
    nameFilters: ["*.qml"]
    sortField : "Name"
    }
    Component
    {
    id: filedelegate
    Text { text: fileName }
    }
    model: foldermodel
    delegate: filedelegate
    } @

    i want to show all the files/directories under the base directory, in a recursive way. does any one have an idea how to do that?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      You should remove:
      @nameFilters: ["*.qml"] @

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0
      • G Offline
        G Offline
        goli
        wrote on last edited by
        #3

        and how can you make it a tree of files from the base folder?
        in other words, when you have a directory you can click on it and get all the included files and directories...
        when i write this code:
        @ListView
        {
        anchors.fill: parent
        FolderListModel
        {
        id: foldermodel
        folder: "C:/Qt/Projects"
        }
        Component
        {
        id: filedelegate

                Rectangle
                {
                    width: 100;height: 20
                    Text { text: fileName}
                    MouseArea
                    {
                        anchors.fill: parent
                        onClicked:
                        {
                            foldermodel.folder  = filePath;
                        }
                    }
                }
            }
            model: foldermodel
            delegate: filedelegate
        }@
        

        it change all the base folder of the tree, and i want to add item to the tree.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          task_struct
          wrote on last edited by
          #4

          Take a look at: "this thread":http://developer.qt.nokia.com/forums/viewthread/5462

          In your delegate you shoud check if element is folder or file and if it is folder you should create a new ListView with FolderListModel filePath.

          "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

          • Linu...
          1 Reply Last reply
          0
          • G Offline
            G Offline
            goli
            wrote on last edited by
            #5

            how can i use this? i didn't understand the example, because the model should be FolderListModel , and this example use the regular ListModel

            1 Reply Last reply
            0
            • T Offline
              T Offline
              task_struct
              wrote on last edited by
              #6

              Try this:

              Create two delegates in two files: FileDelegate.qml and FolderDelegate.qml
              In FileDelegate.qml you will have only @Text { text: fileName } @
              and in FolderDelegate you will have ListView with FolderListModel pointing to fileName.

              ListView delegate should be Loader that loads FileDelegate.qml or FolderDelegate.qml after checking if current element is file or folder.

              And the main QMl file can be FolderDelegate pointing to "C:/Qt/Projects".

              I`ll try to write an example, when I go home, but I think this will work :)

              "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

              • Linu...
              1 Reply Last reply
              0
              • G Offline
                G Offline
                goli
                wrote on last edited by
                #7

                what do you meen bq. in FolderDelegate you will have ListView with FolderListModel pointing to fileName.?

                what should be in FolderDelegate.qml? and how can i pass the folder to this file?

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goli
                  wrote on last edited by
                  #8

                  now it does work, but it's realy slowly, ithink it's because the recursion. do you have an idea how to solve this?

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    task_struct
                    wrote on last edited by
                    #9

                    I think the problem is that you`ve got a lot of ListViews in ListViews. May be you can optimize something. For example:

                    1. Subdirectory should display its content only when its name is clicked
                    2. When some subdirectory is not on focus ( you are working somewhere else ) you can close it.

                    This should reduce number of ListViews :)

                    "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

                    • Linu...
                    1 Reply Last reply
                    0
                    • W Offline
                      W Offline
                      www.rzr.online.fr
                      wrote on last edited by
                      #10

                      Hi,

                      Just a side remark I am also using FolderListModel
                      but I am unsure it is supported by nokia ovi store for symbian platform

                      http://www.developer.nokia.com/Community/Discussion/showthread.php?231131-import-com.nokia.symbian-1.0-with-latest-Qt-SDK-1.1.4&highlight=labs

                      You have been warned

                      http://qt-project.org/doc/qt-4.8/qml-folderlistmodel.html

                      Note: This type is made available by importing the Qt.labs.folderlistmodel module. Elements in the Qt.labs module are not guaranteed to remain compatible in future versions.

                      More details :

                      http://rzr.online.fr/q/symbian

                      --
                      http://rzr.online.fr/q/qt# random notes : rpi, meego, etc

                      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