Search code examples
c++model-view-controllerqt5qlistviewqabstractitemmodel

Catch resetModel events from QAbstractItemModel in QAbstractItemView?


The functions beginResetModel() and endResetModel() emit the signal modelAboutToBeReset() and modelReset(). I want to react on those in the subclassed QAbstractItemView but I cant find any hints in the documentation. Are there any slots/protected funtions to handle those at all?


Solution

  • I dont know if it is the right way but overriding reset() works:

    YourSubclassOfQAbstractItemView.h:

    void reset() override;
    

    YourSubclassOfQAbstractItemView.cpp:

    void YourSubclassOfQAbstractItemView::reset()
    {
        QAbstractItemView::reset();
        updateGeometry();
    }