문제

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.

도움이 되었습니까?

해결책

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

다른 팁

As you can see here, the preferred method is to use the beginResetModel() and endResetModel() functions surrounding your reset code in your model subclass.

This should handle emitting the signal appropriately.

Some of the qabstractitemmodel subclasses might allow you to use model.removeRows(0,model.rowCount()) (others would require you to implement it yourself)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top