[SOLVED] Is there a way to detect changes in fields at application runtime?
-
Hi, is there a way to detect changes to widgets such as lineedit,radiobutton,combobox etc during runtime?
Thanks -
What kind of changes ?
-
detect changes just as change in a lineedit field or radio button, then prompt a dialog box asking if user wants to save changes
-
AFAIK, No, you need to do that explicitly.
-
ermm like how? could you please help to elaborate more?
-
Hi,
You can use a dirty flag that you'll check e.g. when the user closes your UI. You'll need to create a slot for that that and connect your various input widget to it. The signal you'll need to use will depend on the widget.
-
You can directly get notified about changes through the signal/slot mechanism. You can listen to a focus lost event of components as well which does not directly indicate a change but you can check that yourself.
-
hi SGaist, could you help to explain more on the 'dirty flag'? Is there an example I can take a look at? Thank you.
-
Have a boolean member in you class called e.g. _dirty that is originally set to false and that you set to true when one of your input changes. Don't forget to reset it when appropriate.
-
thanks very much!