The objects I am editing can be edited in other GUI elements of the application as well. When the object is saved, it emits a notification to let all the GUI elements if the app know that the data has changed and they need to update. In the table, this notification is the dataChanged signal. If I use the corresponding slot for saving, then whenever the data is saved it will emit a dataChanged signal which will cause the data to be saved again which will emit another dataChanged signal which will cause the data to be saved again and so on...Originally Posted by wysota
The existing model-view framework is not sufficient to meet the needs of this application. Using the dataChanged() signal to cause the object to save will not work because the QTableView is not the only GUI element that can cause this signal to be emitted. Furthermore, a record can be considered "dirty" even if setData has not been called - it may have been modified by another part of the application or even another user using a different instance of the client but the same server, so I need my own isDirty mechanism. In a simple, stand-alone application I would agree that I'm taking the wrong approach, but in this case I don't have many options.I think you have a wrong approach. Instead of providing your own model mechanisms you should use the existing model-view framework to do all the work. If setData() is called, an item has been changed and it can be considered "dirty". You can tag it as such and when submit() is called, you can synchronise the model with the external backend if you use one.
Essentially I am stuck in my save function that lies in the selectionChanged slot. From there I need to cause the delegate's setModelData function to be called somehow.
Bookmarks