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. [Solved] QTreeView expand/expandAll performance
QtWS25 Last Chance

[Solved] QTreeView expand/expandAll performance

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

    Hi everyone,

    I have just started playing with Qt's MVC classes and have created a hierarchical model to display in a QTreeView. Some of the nodes, however, have a fair amount of children and when I expand these nodes (or, heaven forbid, expandAll), the app hangs for a remarkably long time.

    I have read everything I can on lazy model loading and have implemented what I believe to be correct fetchMore and canFetchMore methods, yet this does not seem to make a difference since fetchMore only gets called once on an expand (however, the tree expands to the correct level and to the very last child which I find very confusing).

    So, my questions are:

    1. Does lazy model loading actually affect the expansion of nodes?
    2. Is there a way I could improve the performance?

    I have been banging my head against this for two days now so any help will be appreciated.

    EDIT: Removed link to code

    Thanks!

    http://www.goblincoding.com

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goblincoding
      wrote on last edited by
      #2

      The issue is not with the expand/expandAll methods.

      I removed the fetchMore and canFetchMore implementations and am now doing all the item creation at once. Although this means that, for large data sets, there now is a delay between loading the model and displaying the view, the delay is significantly less than the one previously experienced (I am not yet sure how I am going to "spin" during this load since all the computationally heavy stuff now sits in the GUI thread, but this is minor compared to the total meltdown experienced before).

      Thanks to everyone on the mailing list for pointing out the importance of having an optimised data() method as well as this has also made a huge impact on my app's performance.

      http://www.goblincoding.com

      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