QAbstractListModel returning undefined when cleared and repopulated
-
I have a class derived from QAbstractListModel that is connected to a ListView. When another ListView changes, I need to change the contents of the Model. I can successfully make the alterations to the model and update the ListView. However, I get an undefined being returned at some point in the update. Don't know that it's a big deal since everything works. But it tweeks me. I want to confirm it's what I think. The clearing of the model returns an empty list before the next updates. Is there a better way to set this up? There seems to be no way to clear a ListView and repopulate it easily, that I've found.
beginRemoveRows(this->index(_currentList.size()), 0, _currentList.size()); _currentList.clear(); endRemoveRows(); beginInsertRows(this->index(0), 0, _durationList[ts->string()].size()); _currentList = _durationList[ts->string()]; endInsertRows();
-
Hi and welcome to devnet,
Since you are nuking the whole content and adding new stuff, the beginResetModel/endResetModel pair would likely make more sense here.