I'm writing a QAbstractItemModel for a tree view that represents a hierarchy of QObjects.
I'm storing the pointer to the QObject as the internal pointer in the model indexes.

Sometimes the objects are added/removed from the hierarchy (always outside the view / item model) and I want the model to notify the view about the change.

The problem I'm having is that functions like beginRemoveRows etc say that they need to be called before the removal has happened and functions like endRemoveRows should happen after the data has been removed.

Since I'm reacting to changes happening outside the model this isn't possible as I can be notified of the change having already happened in the storage.
I tried just calling the begin/end functions but doing that causes the model to call parent() passing indexes with objects which have already been deleted.

Is there any way around this issue?