[Qt-interest] QAbstractItemModel

Scott Aron Bloom Scott.Bloom at sabgroup.com
Sat Mar 28 23:41:16 CET 2009


You are not requried to implement the insertRows...

However you ARE required to call beginInserRows and endInsertRows (as
well as the remove)

You shouldn't call layoutChanged()

The issue is the model has changed but the view thinks it's the same...
so it doesn't bother to request the childcounts and everything else.

Scott

> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of TP
> Sent: Saturday, March 28, 2009 3:18 PM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] QAbstractItemModel
> 
> Hi everybody,
> 
> I use model/view/delegate:
> * the model derives from QAbstractItemModel
> * the view is a QTreeView
> 
> So, the model makes the interface between a data structure and the
view.
> My data structure is resizable. All is working fine when I do not
resize my
> data structure. But when I resize my data structure, sometimes it
works not
> completely: for example, an added branch is shown in the QTreeView,
but not
> its leaves.
> 
> I do not forget to emit the signal "layoutChanged()", so I do not
think that
> it is the problem.
> 
> So I have read more carefully QAbstractItemModel documentation, and I
read:
> 
> "Models that provide interfaces to resizable data structures can
provide
> implementations of insertRows(), removeRows(), insertColumns(), and
> removeColumns(). When implementing these functions, it is important to
> notify any connected views about changes to the model's dimensions
both
> before and after they occur[...]"
> 
> So, above, is it "can provide", or should it be "must provide"?
> 
> Said differently, am I compelled to implement insertRows(),
removeRows(),
> etc. methods to keep my view up to date when my data structure is
changing?
> 
> Thanks
> 
> Julien
> 
> --
> python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.\
> 9&1+,\'Z4(55l4('])"
> 
> "When a distinguished but elderly scientist states that something is
> possible, he is almost certainly right. When he states that something
is
> impossible, he is very probably wrong." (first law of AC Clarke)
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list