Handling changes in applications
-
Hello ,
i have a problem to figure out how people do to handle changes in their application
for example when i make some change , add , delete , draw in the application and after that , i click in close
button a Warrning message box will appear to informe me that i have some changes none saved
i guess that people using globale variable , but i'm not sure what the right approche to use it
-
You indeed need to use some global state, usually a simple boolean value is enough. Usually this kind of property is referred to as the "dirty" flag.
QWidget actually includes some helper convenience methods for you in this regard: see "this link":http://qt-project.org/doc/qt-5.0/qtwidgets/qwidget.html#windowModified-prop. You can use this (advantages: it's already there, and cross-platform), or implement your own.
-
[quote author="sierdzio" date="1383393558"]You indeed need to use some global state, usually a simple boolean value is enough. Usually this kind of property is referred to as the "dirty" flag.
QWidget actually includes some helper convenience methods for you in this regard: see "this link":http://qt-project.org/doc/qt-5.0/qtwidgets/qwidget.html#windowModified-prop. You can use this (advantages: it's already there, and cross-platform), or implement your own.[/quote]
Yeah cool!!
but really i don't know ,
when my application contains many windows
mainwindow, and window1,window2 ...etc . and there is somme
changes happned in window2 or window1, how i can detect that one of
this windows is the responsible for that change ?
-
Loop through all your windows and check their state with isWindowModified().