Originally Posted by
wysota
It doesn't matter where you are adding the items from. If you can't see them then it means you are doing it wrong and refreshing will not help because the items are not there. If you are using a model approach, you need to add items according to rules that govern this architecture.
That was very helpful for steve.bush, I'm sure.
You need to make sure that the model knows to send the appropriate events. For example I have a model that uses a QStringList, and does this when I add an item:
beginInsertRows
(QModelIndex(), items.
size(), items.
size());
stringList << newString;
endInsertRows();
beginInsertRows(QModelIndex(), items.size(), items.size());
stringList << newString;
endInsertRows();
To copy to clipboard, switch view to plain text mode
And this when I clear all the items:
beginResetModel();
stringList.clear();
endResetModel();
beginResetModel();
stringList.clear();
endResetModel();
To copy to clipboard, switch view to plain text mode
The beginX() and endX() calls are important. If I leave them out when clearing the items, for example, the QListView only updates when focus changes (it's clicked on, or focus changes from the parent window to another window, etc.). When I wrap the clear operation with those calls, it's updated immediately.
Bookmarks