Issue
I'm using a QTreeWidget to display a large number of items (about 50_000) using addTopLevelItem/addTopLevelItems
, insertTopLevelItem/insertTopLevelItem
and by setting a parent and preceding item to the QTreeWidgetItem
initializer (usually I need a combination of these adding methods).
This works fine but freezes the GUI for a bit. Is there a way to either do this faster or in the background, so that the GUI doesn't freeze? Speed is not paramount, not freezing the GUI is the top priority.
Thanks Matic
Solution
After a lot of code restructuring and testing I can confirm that both @musicamante
's suggestion:
create the top level items without parents, then add all the children, finally call addTopLevelItems()
and @HiFile.app - best file manager
's suggestion:
You can create a QList of top level items and add children to each of the top level items using QTreeWidgetItem::addChild() or QTreeWidgetItem::addChildren(). And once you have the whole structure ready, you just call QTreeWidget::addTopLevelItems(). I.e. you insert all the items to the model in just one call.
are the best solution! It might take some effort to restructure the code, but the result is great: no delays in rendering large numbers of items with.
Thank you both for the answer!
Answered By - Matic Kukovec
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.