[Qt-interest] Checkimg for dirty table model
Petric Frank
pfrank at gmx.de
Tue Sep 14 16:47:35 CEST 2010
Hello,
i access a SQL table (Postgres, MySQL) via a QSqlTableModel instance. The edit
strategy is set to "OnManualSubmit". This can not be changed.
The code looks basically like this:
--------------------------------- cut -----------------------------------
QSqlTableModel *table = new ...;
table->setEditStrategy (QSqlTableModel::OnManualSubmit);
...
do the changes (via the GUI, ...)
...
bool dirty = false;
for (int row = 0; row < table->rowCount (); ++row)
for (int column = 0; column < table->columnCount (); ++column)
dirty = dirty || table->isDirty (table->index (row, column));
if (dirty)
... (for example update a timestamp somewhere else)
--------------------------------- cut -----------------------------------
Do i really have to iterate through all rows and columns to find a changed (and
not committed) field?
The method "isDirty" indicates that QSqlTableModel already maintains a dirty
list. Is there a possibility to obtain this dirty list - for example - as a
list QModelIndex items of changed fields directly ?
Any hints ?
regards
Petric
More information about the Qt-interest-old
mailing list