Saving State..
There isn’t an application today that doesn’t have a “Preference” or “Settings” section. The GRITS viewer and image processing application are no exception. The viewer application needs to preserve information such as “work offline”, “window transparency level”, and “image translation” values. For a long time this was done by reading and writing to a file. Windows programmers eventually achieved this functionality using the system registry. Java developers now have the Preferences API.
The GRITS project is using QT in a C/C++ environment and I was dreading have to deal with saving state or preference information. But then I discovered “QSettings“.
The QT developers think of everything. QSettings lets me store and retrieve information without having to code for each platform. On Windows it uses the system registry, on the Mac OS, XML filesĀ and on Unix INI files are used. QSettings uses simple key/value pairs but also gives the ability to store data in a custom format. Using this is very straight forward.
To store data first create a QSetting object. Then call beginGroup(). “setValue()” adds the information and “endGroup()” completes the process.
QSettings settings();
settings.beginGroup();
settings.setValue();
settings.endGroup();
Here is an example of how I used this to store the window transparency setting.
QSettings settings(”GritsSettings”, “Preferences”);
settings.beginGroup(”viewersettings”);
settings.setValue(”windowTransparency”, windowTransparencySlider->value());
settings.endGroup();
Here is how the information appears in the registry.
Since I need to access this data from various parts of the application I created a Preferences object that hides the QSetting details. I can simple user prefs->getTransparency() or setTransparency() to do the work for me.
Its not too difficult to see how one could use this to store the location and state of windows or other pieces of application information.





Buy:Zetia.Zocor.Seroquel.Lipothin.Nymphomax.Ventolin.Lipitor.Prozac.Cozaar.Aricept.Female Cialis.Amoxicillin.SleepWell.Benicar.Advair.Acomplia.Female Pink Viagra.Lasix.Wellbutrin SR.Buspar….
Buy:Petcam (Metacam) Oral Suspension.100% Pure Okinawan Coral Calcium.Zyban.Nexium.Prevacid.Actos.Human Growth Hormone.Synthroid.Lumigan.Accutane.Prednisolone.Zovirax.Mega Hoodia.Valtrex.Retin-A.Arimidex….