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. How to Create a Model Like QFilesystemModel
Forum Updated to NodeBB v4.3 + New Features

How to Create a Model Like QFilesystemModel

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 642 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.
  • E Offline
    E Offline
    elveatles
    wrote on last edited by
    #1

    I would like to create a model like QFilesystemModel. I am fetching information from a database about directories which I would like to display in a QTreeView. I'm able to do this with QAbstractItemModel, but I can't figure out how to implement the lazy loading aspect of QFilesystemModel. I assume QFileSystemModel is only loading children for parents that are expanded. There are way too many subdirectories within subdirectories to load it all up front. I'd appreciate any help with this.

    1 Reply Last reply
    0
    • E Offline
      E Offline
      elveatles
      wrote on last edited by
      #2

      I realized QAbstractItemModel only calls methods like rowCount in an on-demand way. So I can load the children there. How QFileSystemModel does this in a threaded way is still a bit of a mystery to me though.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        The best way to find out is to take a look at the sources of QFileSystemModel :)

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • E Offline
          E Offline
          elveatles
          wrote on last edited by
          #4

          Thank you. That helps.

          1 Reply Last reply
          1

          • Login

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