Greetings,

I am writing an application where I am receiving a lot of data from the network and have to display it in a QTableView. I can receive hundreds of messages per second and I need the table to remain responsive when data is added or changed. My function that updates the model looks like this:

Qt Code:
  1. ModelItemRowTable::const_iterator rowIter = m_modelItemRows.find(symbol.c_str());
  2. if (m_modelItemRows.end() != rowIter)
  3. {
  4. int row = rowIter.value();
  5. m_modelItems[row].data.Update(quote, fieldUpdateFlags);
  6. emit dataChanged(index(row, 0), index(row, columnCount()-1));
  7. }
  8. else
  9. {
  10. emit beginInsertRows(QModelIndex(), rowCount(), rowCount());
  11. ModelItem item;
  12. item.symbol = symbol.c_str();
  13. item.data = quote;
  14. m_modelItems.push_back(item);
  15. m_modelItemRows[symbol.c_str()] = m_modelItems.count() - 1;
  16. emit endInsertRows();
  17. }
To copy to clipboard, switch view to plain text mode 

where m_modelItems is a list of items and m_modelItemRows is a hash table storing the item rows as values for faster item lookup. This is a 3000 x 9 table.

Now data insertion is very fast as it occurs when the model is created, the problem is when data is changed. I receive a lot of messages at a time and I was wondering how to do it without having to emit the dataChanged signal on every update. I have tried queuing the items and updating the range of queued items at regular intervals (e.g. every 100 ms, 250 ms, 1s) but the view is still not responsive enough and data is not updated as fast as I would like (1 to 4 times per second). Or maybe there is something about the dataChanged() signal that I am am missing?

Any ideas?