PDA

View Full Version : QTreeView expanding perfromance issue



Tilly1986
28th July 2017, 09:46
a model with 400k nodes, and i expand all and collapse all for top node, and then expand it again, QTreeView will stuck, from the call stack , it will insert treeview item. Is there any way to improve it? Thanks.

call stack :
#2 0x00007ffff7426043 in QTreeViewPrivate::insertViewItems(int, int, QTreeViewItem const&) () from /remote/vginterfaces2/verdi_thirdparty/QT/QT485_PACKnew/lib/LINUXAMD64/libQtGui.so.4
#3 0x00007ffff742cbc5 in QTreeViewPrivate::layout(int, bool, bool) () from /remote/vginterfaces2/verdi_thirdparty/QT/QT485_PACKnew/lib/LINUXAMD64/libQtGui.so.4
#4 0x00007ffff742c865 in QTreeViewPrivate::layout(int, bool, bool) () from /remote/vginterfaces2/verdi_thirdparty/QT/QT485_PACKnew/lib/LINUXAMD64/libQtGui.so.4
#5 0x00007ffff742c865 in QTreeViewPrivate::layout(int, bool, bool) () from /remote/vginterfaces2/verdi_thirdparty/QT/QT485_PACKnew/lib/LINUXAMD64/libQtGui.so.4
#6 0x00007ffff742c865 in QTreeViewPrivate::layout(int, bool, bool) () from /remote/vginterfaces2/verdi_thirdparty/QT/QT485_PACKnew/lib/LINUXAMD64/libQtGui.so.4
#7 0x00007ffff742d400 in QTreeViewPrivate::expand(int, bool) () from /remote/vginterfaces2/verdi_thirdparty/QT/QT485_PACKnew/lib/LINUXAMD64/libQtGui.so.4

d_stranz
28th July 2017, 18:48
Is there any way to improve it?

Don't call expandAll() on the root node.

All of the calls you show in your stack trace are the result of computations the tree view must do to determine the layout of the expanded tree. It has to do that before it knows how to draw the tree on screen.

In any case, what is the point of calling expandAll() on a tree with 400K nodes? You can only see a small fraction of them at any time. You would probably be better off to call expandToDepth() instead to show a smaller number of nodes.