[Solved] QTreeView expand/expandAll performance



  • 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!



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.