Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Using QFileSystemModel along QTreeView and QTreeWidgetItem

    General and Desktop
    2
    4
    3389
    Loading More Posts
    • 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.
    • D
      Dimbreath last edited by

      bq. -Project Main File (Always at top)
      --Project Subfile 1
      --Project Subfile 2
      --Project Subfolder 1
      ---Project Subfolder 2
      ----Project Subfile 3
      ----Project Subfolder 4
      -----Project Subfolder 5
      ------Project Subfile 4

      I have a file structure. I read the "project" path files and folders using QFileSystemModel. Then i want to display them using the structure i've posted above using QTreeWidgetItem.

      My principal issue is making the folders and their sub-folders (and maybe even sub-sub folders, let's say we can have LOT of sub-folders). And then placing the files to their correspondent folder.

      Any example / guide on how to do that job in an easy way?

      1 Reply Last reply Reply Quote 0
      • T
        terenty last edited by

        Hi!
        Is your goal just to display it or to display it exaclty with QTreeWidget?

        If you just want to display QFileSystemModel you only need to provide a view onto this model:

        @QFileSystemModel *model = new QFileSystemModel(this);
        QTreeView *tree = new QTreeView(this);
        tree->setModel(model);@

        In case you haven't read: "nice article about model-view pattern in Qt":http://doc.qt.digia.com/main-snapshot/model-view-programming.html

        1 Reply Last reply Reply Quote 0
        • D
          Dimbreath last edited by

          I want to display it using Tree Model. I want to display the results from the QFileSystemModel which gives me files and folders from the path specificed.
          This is to make a "solution or project system".

          Setting the root to the main project of the file and then placing the files, folders (which it's files, and sub-folders) under the root.

          EDIT:

          What it would be is something like this:

          1. Get the files and folders from the specified root path on the QFileSystemModel
          2. Set the QTreeView root to the main project file. (aka, for example, MyProject.pro. Main file of projects)
          3. Get the all files that are in the same folder as the .pro file and add them to the Tree.
          4. Get all the folders in the same folder as the .pro file
          5. Check if inside those folder there are files and/or folders. If there are, add them. (Then if inside those sub-folders there are more folders and files, continue until the end).

          Seems to be a bit complicated and confusing.

          1 Reply Last reply Reply Quote 0
          • D
            Dimbreath last edited by

            Bumping the thread... Still haven't found anything to do this.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post