Existing setup:

I have a custom QAbstractListModel with an attached QTableView. The model receives data from two sources - one source's data goes into a vector and the other source's data goes into a map. The model then provides data for column 1 from the vector and the data for column 2 from the map.

Each time data arrives from source 2 it gets inserted into the map and the beginResetModel/endResetModel signals are emitted.

The problem:

A flood of data from source 2 arrives. Each bit of data that arrives results in beginResetModel/endResetModel being emitted, which results in the QTableView doing a lot of work and the GUI locks up for a while while the data is being processed.

It's not feasible to emit dataChanged instead of beginResetModel/endResetModel because that would require a linear search through the vector to determine which the QModelIndex of the cell to be changed.

My current solution:

Each time some data arrives from source 2, I emit beginResetModel. Then I start/restart a timer that runs for 500ms. When the timer completes the endResetModel signal is emitted. In this way if a flood of data arrives from source 2, endResetModel is only called once after all the data has been loaded into the model (assuming that the time gap between data arriving is less than 500ms of course).

Possible problem with my solution:

I emit beginResetModel every time I receive data from source 2, but I don't emit endResetModel every time. Does there always need to be an endResetModel for every beginResetModel?

Has anyone got any ideas on how to improve this?