How to reset model in Qt?

user1899020 picture user1899020 · Feb 7, 2013 · Viewed 15.4k times · Source

I am using Qt model/view framework. When I reset the data in the model, I have to reset the model to let views update also. How to do it? I found a signal modelReset(QPrivateSignal); in the QAbstractItemModel, Is this the way to solve it? How to emit the signal? Thanks.

Answer

cmannett85 picture cmannett85 · Feb 7, 2013

You call beginResetModel() before you reset your data, and then endResetModel() once you have finished. The endResetModel() emits the private signal.