I am using a QTableView. Each row in my table represents an object, and each column an attribute of the object. When the user selects a new row I want to save the deselected row. I have connected the QTableView's selectionModel's selectionChanged signal to a slot that calls the save method the deselected object, and it works well.

I created a custom delegate as well for my QTableView. The problem I am having is that if I am editing something using the delegate, and then I click on a different row while the editor is still open, then the selectionChanged signal fires before the delegate's setModelData method is called. This means that the object is saved before the editor's data is set, so the changes are lost.

I have looked at the Qt documentation and it mentions a releaseEditor method of QItemDelegate that does not exist In my save method I have access to my delegate class, but I cannot call the setModelData method because I don't know which widget and index to pass in to the method. Can anyone suggest something I could try in order to get the setModelData method to be called before the object is saved, or how to determine which widget and index to pass to setModelData?