When you modify (or add to) the underlying data (you passed the std::vector by pointer) the model will obviously not know about it.
So, you have to choices:
i) make all modifications by interacting with your model class (and emit the appropriate signals there; that way you have the possibility to be more precise and say things like "20 rows have been added" - allowing you to keep the current selection...)
ii) modify the underlying data and tell the model afterwards about it, so it can reset itself (QAbstractItemModel::reset(); you will lose the current selection) that way
usually, when dealing with a model, all changes to the models data should be made through the model. otherwise you kinda defeat its purpose...
HTH




Reply With Quote
Bookmarks