PDA

View Full Version : How to undo the changes made in a widget.



RJ
14th August 2012, 09:23
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.

yeye_olive
14th August 2012, 09:51
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.

RJ
14th August 2012, 10:46
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.

wysota
15th August 2012, 00:29
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.