[Qt-interest] QAbstractItemModel

TP paratribulations at free.fr
Sat Mar 28 23:18:14 CET 2009


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)




More information about the Qt-interest-old mailing list