[Interest] Regarding QtreeWidget

william.crocker at analog.com william.crocker at analog.com
Fri Mar 4 17:56:33 CET 2016


On 03/04/2016 11:24 AM, André Somers wrote:
>
>
> Op 04/03/2016 om 13:20 schreef william.crocker at analog.com:
>> On 03/04/2016 03:06 AM, Roshni Lalwani wrote:
>>> I have application in which I am planning to use a QtreeWidget . The maxinum
>>> number of elements in the treeWidget can go uptp 500 . COuld you let me how will
>>> be performance of using QtreeWidget for 500 elements . Will it lead to some
>>> performance degradation
>>>
>>
>> Use a QTreeView with an underlying model and performance of the tree widget
>> will no longer be a concern.
>

I said that performance of "the tree widget" would no longer be a concern.

:-)

If a tree had a large number of node, I would not use a tree widget for the high
time-0, O(N) load time. The beauty of the view/model approach is that the view will
only request information on a small number of indexes at any given time and,
correspondingly, the underlying model would only have to service a small number
of indexes at any given time. Especially at time 0.

> Nonsense.
> It all depends on your implementation of the model then, and writing good tree
> models is not trivial. I agree that generally a "real" model is much to be
> prefered, but your statement as-is doesn't make much sense to me.
>
> I think the merrits of QTreeWidget (and all the view like Q*Widget classes) is
> debatable, but I don't think performance is the major pain point here. I would
> recommend to consider using QStandardItemModel with a QTreeView instead if you
> like the item-based API that much. Also, consider wrapping it up in your own
> model subclass with a sane API that suits your application, instead of filling
> and accessing your model from different places in otherwise unrelated code. This
> will make it easier to swap out the QStandardItemModel based model for a custom
> model later on if needed.
>
> André
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>




More information about the Interest mailing list