[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: How I refresh a QTreeView if the model data changes?
From:       Robert Knight <robertknight () gmail ! com>
Date:       2009-12-31 17:27:18
Message-ID: 13ed09c00912310927w3ead5d1he7beaac85692bc0e () mail ! gmail ! com
[Download RAW message or body]

> Could it just use the QStandardItemModel instead?  Or even just the QTreeWidget.

I would suggest avoiding QListWidget/QTreeWidget.  They seem simple to
use at first but they suffer from poor performance (once you start
dealing with a few hundred or more items) and a lack of flexibiliy
because the model and view are bound together.  For example, if you
wanted to add a way to sort or filter the contents of the list or tree
then this can be done quite easily using a separate model/view by
adding a QSortFilterProxyModel between the original model and the
view.  With QList/Tree/TableWidget this is not possible because they
do not allow the model to be changed.  Additionally, it is not easy to
re-use generic code for manipulating QAbstractItemModels with
QList/Tree/TableWidget.

QStandardItemModel + QListView/QTreeView would be a better choice for
small-medium sized models and simple data.  When you get to dealing
with large models (thousands of items) and/or rich per-item data then
I would consider a custom model.

Regards,
Robert.

2009/12/31 kuddel-fl <kuddel-fl@gmx.de>:
> Many thanks!
>
> but it's to difficult to log which lines have to removed and which to
> inserted, because the data are stored in another class.
> Now I simply call reset(). Maybe it is slow but it works.
>
> Ulrich Weigelt
>
>
>
> Am Mittwoch, 30. Dezember 2009 21:38:49 schrieb John Tapsell:
>> 2009/12/30 kuddel-fl <kuddel-fl@gmx.de>:
>> > Hi!
>> >
>> > I develop the mail client KShowmail. It looks for new mails on POP3
>> > servers and show they in a list.
>> >
>> > To show the mails I use a QTreeView. The model for this is derived from
>> > QAbstractItemModel. The received mails a stored in a mail list object.
>> > The model gets all data about received mails live from the mail list. The
>> > model doesn't store some data.
>>
>> You need to call beginInsertRows and endInsertRows  functions.
>>
>> Making a custom model is difficult - expect it to take half a year to get
>>  right.
>>
>> John
>>
>> >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to
>> >> unsubscribe <<
>>
>
>>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
>
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic