Undo by saving the whole model-state not actions possible with QUndoStack?
-
wrote on 27 Jul 2018, 08:56 last edited by
Hi,
i have a project where there is a QAbstractItemModel that can be manipulated by some actions.
The changes to the model sometimes are a bit complicated, so it is hard to keep track of all the action and the opposite of them.
Therefore I think the easiest way to implement Undo / Redo would be to just save the model state to a stack each time something is changed and load the old model for undo.The problem I see with this approach is, that for loading back the old model I also have to "undo" the beginInsertColumns() beginRemoveRows() begindeleteRows() and so on for the ItemView.
Is there maybe some example for such a case?
-
wrote on 27 Jul 2018, 10:52 last edited by
Even if it might be quite inefficient, if you have control over the model, you can call
beginResetModel
/endResetModel
to signal the complete change to the view
1/3