Results 1 to 4 of 4

Thread: How to undo the changes made in a widget.

  1. #1
    Join Date
    Aug 2012
    Posts
    29
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question How to undo the changes made in a widget.

    Hi all,

    I am having a window in which multiple widgets are there like lineedit and combobox etc. user is allowed to do the changes and after changing he/she can save the changes. before saving it I am checking that iany changes made or not using IsWindowModified. now after checking it I am showing a warning message in which three buttons yes No and cancel are there. I want to revert the changes wehatever made in that window if user clicks on NO.
    please help me how to do it? I mean is there any function available in qt for undoing the changes of the widgets(as IsWindowModified is there for checking the changes made or not)

    thanx in advance.

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to undo the changes made in a widget.

    I do not think such a thing exists. You could implement that yourself. Design a data structure to store the information presented in the window and write a function to set the widgets up to reflect the information in such a structure. Call that function when initializing the window and call it again when you need to revert the changes. You can detect changes by raising a flag when one of the relevant properties of the widgets is modified.

  3. #3
    Join Date
    Aug 2012
    Posts
    29
    Thanked 2 Times in 1 Post
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Unhappy Re: How to undo the changes made in a widget.

    thanks for the reply.

    I thought about it before but didnt implement it because it will be a huge work as my window has lots of information. for checking the changes as I already said that we have IsWindowmodified property which returns true if anything is modified. But for undoing those changes I didnt get any1.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to undo the changes made in a widget.

    QLineEdit has a default value property you can use to store the initial value and then just reset it when the user rejects the changes. You can use a dynamic property for other widgets for the same purpose.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Syncing QTextDocument's undo stack with custom undo stack
    By Dini Selimović in forum Newbie
    Replies: 0
    Last Post: 24th June 2012, 13:11
  2. QtableWidget UNDO
    By afro_cv in forum Qt Programming
    Replies: 15
    Last Post: 5th September 2011, 08:19
  3. Replies: 7
    Last Post: 18th August 2011, 14:43
  4. Custom made widget - advanced button
    By KjellKod in forum Newbie
    Replies: 2
    Last Post: 10th November 2010, 13:44
  5. buggy undo example
    By Gopala Krishna in forum Qt Programming
    Replies: 2
    Last Post: 21st August 2007, 19:33

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.