How can I undo or revert an user entry on a QTableView popuplated by QStandarItemModel?
I have connected dataChanged signal with a handler where I validate the data…
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(validateData(QModelIndex,QModelIndex)));
…but in case user entry is wrong I want to revert or undo the user entry to the previous value of the item.
I have read about revert() member inherited from QAbstractItemModel but I can’t understand how it works exactly. Documentation says “Lets the model know that it should discard cached information.” but I’m not sure whether the data the user entered is cached or is already stored on the model.
Anyway if I try…
model->revert();
…after a wrong user entry it does not work.
Thanks in advance!
Check out Qt’s undo framework. The introduction at the documentation says: