Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Create undo actions

[SOLVED] Create undo actions

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 860 Views
  • 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 Offline
    S Offline
    sharon_obl82
    wrote on last edited by
    #1

    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
    0
    • N Offline
      N Offline
      nanthiran_2005
      wrote on last edited by
      #2

      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
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved