When subclassing QAbstractItemModel for developing a tree model, it is unclear to me when the methods QAbstractItemModel::beginAddRows etc should be called, in particular when nested calls are concerned.
More concrete, suppose an item x is removed, along with its subitems, is it ok to only call beginRemoveRows and endRemoveRows for the item x, w.r.t. its removal from its parent item, or should these methods also be called for the subitems below x? Is it wrong to call these begin end methods for the sub items below x after the methods have been called for item x? Will that fail, or will it only be inefficient?
When removing toplevel items, can these methods be called with QModelIndex() as parent?
Likewise, for adding a hierarchy of items at once, is it harmful to call beginInsertRows for a subitem before the parent itself is beginInserted / endInserted?
I have the impression that these life cycle constraints and policies regarding the insertion/removal of a hierarchy of items at once are not clearly documented, or did I miss something.
Bookmarks