×
Namespaces

Variants
Actions
Revision as of 13:35, 3 April 2009 by Forum Nokia KB (Talk | contribs)

Qt and Symbian settings management comparison

From Nokia Developer Wiki
Jump to: navigation, search


Template:KBTS

Article Metadata
Compatibility
Platform(s): S60 3rd Edition FP2, S60 5th Edition
Symbian
S60 5th Edition
S60 3rd Edition FP2
Article
Keywords: QSettings
Created: (30 Mar 2009)
Last edited: Forum Nokia KB (03 Apr 2009)

Overview

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.


Description

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.

Operations S60/Symbian OS 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.
Class CRepository QSettings
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.


Solution

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.


 MyApplication::MyApplication(QWidget *parent)
: QWidget(parent)
{
//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.setValue("
Engine/TimeOutPeriod", value);
//Setting a string value
QString string (“This is sample”); //or we can also assign QVariant string(“This is sample”)
setting.setValue(“Engine/MessageTitle”, string);
//Getting an int value;
int settingval = setting.value("
Engine/TimeOutPeriod ").toInt();
//Getting a string value
QString title = setting.value("
Engine/MessageTitle ").toString();
}
53 page views in the last 30 days.