[Solved] Big performance issue with TreeView
I'm having big performance issues with a QTreeView and a custom model. I'm using PyQt 4.7.4 which is based on Qt 4.6.
To demonstrate the issue, I've created a 'one-child-per-parent' model, which is naturally as deep as it can get. Now, the issue becomes apparent when expanding the whole tree. It takes about 1.5 minutes to expand a tree of 5000 items on a Intel Core7 860. If I can't optimize performance, that would be a showstopper for my project, as I need to handle around 100000 items, however not as deeply nested. Profiling shows, that some methods like parent() of the QAbstractItemModel are called 12'503'272 times for a model with 5000 items!! This can't be the proper behaviour, can it?
What's going on there? I would have thought it's Python related, but after having seen the profiling I'm puzzled.
Does anyone have similiar issues? Are there performance tipps besides the setting of the uniformRowHeights property? Or do I have to face the fact that Qt is not the right Gui toolkit for handling large data trees? (Which would be a shame, now that I've started to understand and to like it quite a lot.)
Any thoughts and recommendations are highly appreciated.
Are you sure that you need all 100000 items at one time? Maybe you can make lazy-loading with fetchMore() method?
Knacktus, yes, I had same problems with QListView and 100000 elements so I had written my own view and model :(
This issue is something that "itemviews-ng":http://qt.gitorious.org/qt-labs/itemviews-ng is trying to tackle. There hasn't been an update to it since April this year, but hey, that might mean it's scheduled for Qt 5
first, thanks for your replies.
I have good news: Following a hint from the PyQt Forum I installed a Python wrapper using Qt 4.7. Now I can confirm what some guy has observed: There's a massive improvement in Qt 4.7.
My example now takes 0.266 seconds to expand compared to 90 seconds with Qt 4.6!!!! The numbers of method calls also look much more reasonable.
Good to know :)