Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [SOLVED] Create undo actions

    General and Desktop
    3
    3
    695
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      sharon_obl82 last edited by

      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

      1 Reply Last reply Reply Quote 0
      • N
        nanthiran_2005 last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • SGaist
          SGaist Lifetime Qt Champion last edited by

          Hi,

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 0
          • First post
            Last post