[Qt-interest] QtreeWidget::addTopLevelItem() very slow method

Andreas Pakulat apaku at gmx.de
Mon Jul 12 12:14:40 CEST 2010


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

-- 
You will soon forget this.



More information about the Qt-interest-old mailing list