I have a QTreeView that displays the contents of a custom QAbstractItemModel-based class. The custom model wraps a data structure that can be updated when the app recomputes results. When this happens, the model calls beginResetModel() / endResetModel(), which results in a modelReset() signal. All is fine with this part.

When the tree view receives notification of an updated model, I want to expand the root item to display all of its top-level children. So, I have made a connection between the model's modelReset() signal and a slot in the widget that contains the QTreeView. In this slot, I call QTreeView::expandToDepth( 1 ). Unfortunately, it appears that this slot is being invoked before the tree view updates itself, because I can see the view's contents disappear and then reappear (unexpanded) after leaving the slot. (I have replaced the expandToDepth() call with expandAll() with the same result).

Is there a way I can determine that the tree view has finished its internal update after a model reset so I can expand the root node?