Here is something I wanted to share. It’s a pity something similar isn’t implemented by the Trolls. But then again, it doesn’t require much coding either.
bool isDirty() const { Q_ASSERT(orientation() == Qt::Horizontal); Q_ASSERT(rootIndex() == QModelIndex()); for(int i = 0; i < model()->columnCount(); i++) { QWidget *mapWidget = mappedWidgetAt(i); if (mapWidget){ QByteArray p = mappedPropertyName(mapWidget); QModelIndex idx = model()->index(currentIndex(), i); if (idx.data(Qt::EditRole) != mapWidget->property(p)) return true; } } return false; } |
One use is to check whether an update is required before going to the next record…
PS Other way one could achieve the same thing by adjusting the source code because the “mappings”-container is in the private implementation of QDataWidgetMapper.
Hi,
I suggest this code instead (with a more intensive memory usage):
Comment by ericmaeker — 08/12/2012 @ 00:06