PDA

View Full Version : QSqlTableModel Dirty Flag?



ChrisW67
1st September 2009, 02:07
Hi Guys and Gals

Other than iterating over every index in the model with QSqlTableModel::isDirty(), is there a good way to tell if a QSqlTableModel is in need of a call to submitAll() or revertAll()?

I track my own row insertions and deletions. For edits I have been catching the model's dataChanged() signal but it gets sent when a cell is edited (and not cancelled) even if the value does not change, i.e. press F2 to edit the cell them move off it without changing the value. The isDirty() method similarly returns true for this cell.

There does not seem to be a good flag that could be used to enable/disable a Commit/Revert button pair.

Cheers
Chris W

wysota
1st September 2009, 07:08
You can reimplement QAbstractItemModel::setData to ignore such edits and at the same place you can mark the model as dirty.

ChrisW67
4th September 2009, 09:15
I did more-or-less what you describe.