This is expected behaviour.
The standard views are not containers of widgets, each cell is drawn when necessary. The widget used for editing is only created and superimposed on top of the view whenever an editing trigger is generated. The delegate is then called to create the appropriate editing widget and the location and size of the cell are passed in as an argument.
The view retains ownership of the editor widget because, whenever focus is lost, you can obviously not be able to edit anymore so the view deletes the editor.
If you do not pass anything back in the setModelData
function, the model will not be updated. It is not correct to say that the model is set back to the original data because it never gets changed in the first place.
What I would suggest you try is setting the QFileDialog
to open modally (editor.setModal(true)
) so that the dialog has to be closed before focus can be transferred to another widget.