Pregunta

I use C++, Qt 4.8.5, Visual Studio 2010, SQLite. I have a Qt-based GUI application, which contains QTableView. The program analyzes some data and changes some cells without adding/removing rows. I use QTimer for refreshing QTableView using OnManualSubmit mode. Is it safe to call submitAll() method in the timer slot for the model several times even if there are no modifications? If submitAll() fails, then do I have to call select() method of my model manually? What about row fetching for SQLite - do I need it after submitAll() call in order to watch modifications of cells in the 257-th and further rows?

Sometimes I've got last error something like "Parameter count mismatch" (QSqlError::StatementError) after the second'submitAll()' call. What is the possible reason? The program is multithreaded, working threads send data to the main thread. The timer triggers every 3 seconds (the changes are buffered). It is instead of instant cell update in QTableView.

¿Fue útil?

Solución

You should not update your view directly (or by timer - it's a big overhead). You must call emit dataChanged( ... ); on each data change in model. But if you want a dirty hack, you may simply call (from model) 'emit dataChanged( QModelIndex(), QModelIndex() );' when you need to update your view.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top