View Full Version : turning widgets to original state

21st September 2009, 09:16

Sorry, I'm a beginner, but I'm not sure if this is a beginner question or not. I am using PyQt 4 and Python 2.6.

After initializing the GUI that I have developed, the user may change a few things, but is there a way for the GUI's widgets to return to its default or original state, like the state it was when it was first loaded? E.g. the tables were initially empty, so all the tables would go back to being empty?

Is there an existing function to accomplish this, or do I have to manually code to undo all the changes?


21st September 2009, 09:24
Hi, there is QUndoStack and friends, but I think those are overkill in your case. The simplest way would probably be to just store the initial value somehow (you could subclass your widget and add a "reset" method) and use this to re-init your widgets.


21st September 2009, 09:35
wow! Thanks Ginsengelf! Even if I don't use undostack to undo everything in my GUI, it will definitely be handy for my GUI's undo button. Thanks for the fast reply! :)