Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Qt and Symbian settings management comparison
This article provides a comparison of settings management between Symbian OS and Qt. Sample code for creating, setting, and getting settings values is also given below.
Settings are stored in form of key/value pairs in both Symbian and Qt. However, there are differences in the paths where the settings files are stored in Symbian OS and Qt.
|Settings mechanism||Central Repository||Conf file|
|Key creation||Settings (keys) are predefined through xls or confml. A default value is assigned to them.||Settings (keys) are created dynamically from the application and stored in the .conf file.|
|Storage format of settings file||Platform creates a .cre file where the values set by the application are stored/restored. The .cre file is not in human readable format.||No .cre file generated. Directly stored in human readable .conf file.|
|Organisation of settings keys||No hierarchy of settings.||There is a hierarchy that can be maintained in keys. For example, all settings pertaining to UI can be put as subkeys under the main UI key.|
|Accessing settings that are stored in platform-specific format||Possible to access platform/other application settings because all are in .cre format.||Possible to access keys/values stored in central repository through extension classes such as XQSettingsManager.|
|Creating instance of setting class||CRepository::NewL||QSettings settings("CompName", "AppName"); A directory is created which has CompName and a conf file is created in the directory with AppName.|
|Setting a value||CRepository::Set||QSettings::setValue|
|Getting a value||CRepository::Get||QSettings::value<tt>|
|Notifications for change in settings||Possible through class <tt>CCenRepNotifyHandler.||No direct class to monitor changes in values of QSettings keys. Possible to monitor cenrep key changes through XQSettingsManager and their associated classes.|
In a Qt application you can use either QSettings or continue to use cenrep (through the CRepository class or preferably Mobile Extensions Mobile_Extensions#13._Settings_Manager_API). The QSettings class provides persistent platform-independent platform settings.
The following example illustrates the creation of settings in Qt.
//The company name and application name need to be passed as a parameter.
//The path of storing the settings is based on these input parameters
QSettings setting(“Company", "MyApplication");
//Setting an int value
QVariant value = 10; //or we can also assign int value = 10
//Setting a string value
QString string (“This is sample”); //or we can also assign QVariant string(“This is sample”)
//Getting an int value;
int settingval = setting.value("Engine/TimeOutPeriod ").toInt();
//Getting a string value
QString title = setting.value("Engine/MessageTitle ").toString();