Unsolved Code for an Undo option
-
How to code for an undo option ....Any help is appreciated.
-
hi and welcome
there is support viahttp://doc.qt.io/qt-5.5/qundo.html
But that said, it really depends on what you want to undo and how many levels back.
So it comes down to what kinda of data your application handles and what you do it and
what undo will do.Simple undo from say Delete is easy, as you can keep lasted
deleted object around until next delete.you can have a look at this example
http://www.walletfox.com/course/qundocommandexample.php -
@mrjj i am developing Linux calculator for that the undo is everything that we entered will be going in reverse format....i hope you understood..
-
@vIJI
Well you want to be able to undo actual sub calculations
or just the entered text ?
So
5+6-4
undo
5+6
or what will it undo ? -
yup exactly like.....
5 + 4 + 3
equal
result = 12
if again added
12 + 2
equal
result = 14and now when you hit undo it should show the previous expression
i.e...
12 + 2
again undo
ull get 12
undo
5 + 4 + 3
undo
"no undo history" -
Ok so the easy way is just to store a QUndoCommand each time
the state changes. Like add or remove digit.
Enter should be a bit special as you will have to keep the
buffer before doing the calc.I think the undo system will fully support your case.
Alternative, you could just store the current Input (1+2)
in a QStringList each time its changed
and then just take last string from there on undo. -
Ok thank you very much You were helpfull...