[Qt-interest] QtreeWidget::addTopLevelItem() very slow method
Roland Tollenaar
rwatollenaar at gmail.com
Mon Jul 12 16:51:37 CEST 2010
hi Andreas,
Thanks, in the intrim I have discovered that it is faster to add them
all at once.
Regards,
Roland
Andreas Pakulat wrote:
> On 12.07.10 11:00:49, Roland Tollenaar wrote:
>> It always strikes met that adding an item to a treewidget, even if the
>> item already exists, is a very slow operation.
>>
>> Is there anyone who knows the technical reason for this and consequently
>> whether (perhaps at the cost of some concession) this performance can be
>> improved.
>>
>> PS the slowness is not directly noticable for small datasets but at 1000
>> or more items to be added the issue becomes clearly evident.
>
> Are you adding each item individually or all at once? Its not very
> surprising that adding them individually causes performance problems as
> each addition will cause the tree layout to change etc. Also for that many
> items its usually better to write a custom model and use QtreeView, the
> *widget versions goal is "ease of use" not performance. With a custom model
> you could inform the view about the insertion of 1000 new items at once,
> causing only 1 layout re-calculation.
>
> Andreas
>
More information about the Qt-interest-old
mailing list