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

Malyushytsky, Alex alex at wai.com
Wed Jul 14 01:40:41 CEST 2010


Combination of :

bool    QWidget::updatesEnabled () const
void    QWidget::setUpdatesEnabled ( bool enable )

may serve the same purpose and you can avoid creating temporary containers just in order to add items.

Regards,
 Alex



-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Andreas Pakulat
Sent: Monday, July 12, 2010 3:15 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] QtreeWidget::addTopLevelItem() very slow method

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.
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”

“Please consider our environment before printing this email.”




More information about the Qt-interest-old mailing list