PDA

View Full Version : In model/view: how to make the view to be aware that the model content has changed



schall_l
1st February 2010, 11:12
Let me take example on itemviews/simpletreemodel
In this example the model is filled when the application starts, then the model is set for the view to present it.
The data representedby the model is never changing.

Now my question is the following:
Supposing that we have a model which data is changing over the time.

How should the model be implemented when data has to be added to it internal data holder so that the view gets informed that the data of the model has changed and by consequence adapts automatically it representation of the model ?

franz
1st February 2010, 18:42
Check the QAbstractItemModel docs for

dataChanged(QModelIndex, QModelIndex);
beginInsertRows(int, int);
endInsertRows();
beginRemoveRows(int, int);
endRemoveRows();

and other functions like that.