Important: Please read the Qt Code of Conduct -

[SOLVED] Create undo actions

  • Hi,
    I have a form with a few lineedits and a few buttons,one of them is the Undo button. The operation of this button is just to undo and retrieve back the previous value in the line edit fields. I've tried the undo() function but it clears up all the fields, not remembering the previous value in the field. Can someone please help me on code here?
    Thank you

  • Probably you can save the previous values in a stack, and create your own function as a slot when the button is pressed. In the function you could retrieve the old values from this stack and write it back on to the line edits.

    PS: I am not sure if this is the best practice.

  • Lifetime Qt Champion


    You should take a look at the QUndoCommand and friends classes. It looks exactly like what you are needing

Log in to reply