NIteLordz
29th January 2015, 01:47
Currently i am displaying a tree using a QStandardItemModel. I wanted to implement Undo/Redo for editing the branch names. I connect to itemChanged(QStandardItem*) and i have created my undo and redo methods. However, when i call undo, i setText on the item, at which point a new itemChanged(QStandardItem*) fires, creating a new QUndoCommand and then things get lost.
I implemented a "hack" where i set a flag in Qt::UserRole+1 when the undoCommand is issued, and i check before issuing the command. This works fine.
My question is, is there a more elegant route to using Undo with the QStandardItemModel, without having to subclass the QStandardItemModel.
I implemented a "hack" where i set a flag in Qt::UserRole+1 when the undoCommand is issued, and i check before issuing the command. This works fine.
My question is, is there a more elegant route to using Undo with the QStandardItemModel, without having to subclass the QStandardItemModel.