Hi
I am using a QDataWidgetMapper with a QSqlRelationalTableModel (Manual edit strategy). When a row is inserted into the model, I want the datawidgetmapper to display that row after it is saved to the database. I understand that when a row is inserted into the model, the model indexes are invalid and so I have been looking at using a QPersistentModelIndex to hold the index of the new row. The problem that I am having is that the persistent index appears to be invalid after model.submitAll.
sample code:
row = self.detailMapper.currentIndex()
self.detailMapper.submit()
self.model.submitAll()
self.detailMapper.setCurrentIndex(persistentIndex)
row = self.detailMapper.currentIndex()
persistentIndex = QPersistentModelIndex(self.model.index(row,0))
self.detailMapper.submit()
self.model.submitAll()
self.detailMapper.setCurrentIndex(persistentIndex)
To copy to clipboard, switch view to plain text mode
Is this the right approach and how do I use persistent model indices correctly. I have looked at the documentation and posts on this forum but am not able to solve my problem.
Thanks in advance
Bookmarks