Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using QFileSystemModel along QTreeView and QTreeWidgetItem

Using QFileSystemModel along QTreeView and QTreeWidgetItem

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 3.6k 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.
  • D Offline
    D Offline
    Dimbreath
    wrote on last edited by
    #1

    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
    0
    • T Offline
      T Offline
      terenty
      wrote on last edited by
      #2

      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
      0
      • D Offline
        D Offline
        Dimbreath
        wrote on last edited by
        #3

        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
        0
        • D Offline
          D Offline
          Dimbreath
          wrote on last edited by
          #4

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

          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