Home · All Classes · Grouped Classes · Annotated · Functions

QTranslatableSettings Class Reference

The QTranslatableSettings class provides persistent application settings that can be translated. More...

    #include <QTranslatableSettings>

Inherits QSettings.

Public Functions

Additional Inherited Members


Detailed Description

The QTranslatableSettings class provides persistent application settings that can be translated.

QTranslatableSettings is functionally equivalent to QSettings except that strings read by QTranslatableSettings can be translated.

Translatable settings are denoted in the settings file by square brackets '[]' in the key. For example:

    [Plugin]
    Name[] = Clock
    [Translation]
    File=clockplugin
    Context=Clock

The Name key is translatable and the [Translation] group specifies the file containing the translations.

Caution should be used when passing a QTranslatableSettings object to a function that takes a QSettings& argument, since that function will not use any translations.

See also QSettings.


Member Function Documentation

QTranslatableSettings::QTranslatableSettings ( const QString & organization, const QString & application = QString(), QObject * parent = 0 )

Constructs a QTranslatableSettings object to access settings of the application called application from the organization called organization with parent parent.

For example:

    QTranslatableSettings settings("Moose Tech", "Facturo-Pro");

The scope is QSettings::UserScope and the format is QSettings::NativeFormat.

See also Fallback Mechanism.

QTranslatableSettings::QTranslatableSettings ( Scope scope, const QString & organization, const QString & application = QString(), QObject * parent = 0 )

Constructs a QTranslatableSettings object to access settings of the application called application from the organization called organization with parent parent.

If scope is QSettings::UserScope, the QTranslatableSettings object searches user-specific settings before searching system-wide settings as a fallback. If scope is QSettings::SystemScope, the QTranslatableSettings object ignores user-specific settings and provides access to system-wide settings.

The storage format is always QSettings::NativeFormat.

If no application name is given, the QTranslatableSettings object will only access the organization-wide locations.

QTranslatableSettings::QTranslatableSettings ( Format format, Scope scope, const QString & organization, const QString & application = QString(), QObject * parent = 0 )

Constructs a QTranslatableSettings object to access settings of the application called application from the organization called organization with parent parent.

If scope is QSettings::UserScope, the QTranslatableSettings object searches user-specific settings before searching system-wide settings as a fallback. If scope is QSettings::SystemScope, the QTranslatableSettings object ignores user-specific settings and provides access to system-wide settings.

If format is QSettings::NativeFormat, the native API is used for storing settings. If format is QSettings::IniFormat, the INI format is used.

If no application name is given, the QTranslatableSettings object will only access the organization-wide locations.

QTranslatableSettings::QTranslatableSettings ( const QString & fileName, Format format, QObject * parent = 0 )

Constructs a QTranslatableSettings object to access the settings stored in the file called fileName, with parent parent. The file is created if it does not exist.

If format is QSettings::NativeFormat, the meaning of fileName depends on the platform as follows:

If format is QSettings::IniFormat, fileName is the name of an INI file.

See also QSettings::fileName().

QTranslatableSettings::QTranslatableSettings ( QObject * parent = 0 )

Constructs a QTranslatableSettings object for accessing settings of the application and organization set previously with a call to QCoreApplication::setOrganizationName(), QCoreApplication::setOrganizationDomain(), and QCoreApplication::setApplicationName().

The scope is QSettings::UserScope and the format is QSettings::NativeFormat.

The code

    QSettings settings("Moose Soft", "Facturo-Pro");

is equivalent to

    QCoreApplication::setOrganizationName("Moose Soft");
    QCoreApplication::setApplicationName("Facturo-Pro");
    QSettings settings;

If QCoreApplication::setOrganizationName() and QCoreApplication::setApplicationName() has not been previously called, the QTranslatableSettings object will not be able to read or write any settings, and QSettings::status() will return AccessError.

On Mac OS X, if both a name and an Internet domain are specified for the organization, the domain is preferred over the name. On other platforms, the name is preferred over the domain.

See also QCoreApplication::setOrganizationName(), QCoreApplication::setOrganizationDomain(), and QCoreApplication::setApplicationName().

QTranslatableSettings::~QTranslatableSettings ()

Destroys the QTranslatableSettings object.

Any unsaved changes will eventually be written to permanent storage.

QStringList QTranslatableSettings::allKeys () const

Reimplemented for internal reasons.

See also QSettings::allKeys().

QStringList QTranslatableSettings::childKeys () const

Reimplemented for internal reasons.

See also QSettings::childKeys().

bool QTranslatableSettings::contains ( const QString & key ) const

Reimplemented for internal reasons.

Returns true if there exists a setting called key; returns false otherwise.

If a group is set using beginGroup(), key is taken to be relative to that group.

See also QSettings::contains().

QVariant QTranslatableSettings::value ( const QString & key, const QVariant & defaultValue = QVariant() ) const

Returns the value for setting key. If the setting does not exist defaultValue is returned.

If no default value is specified, a default QVariant is returned.

If the key is translatable, that is, it has square brackets [] after it in the INI settings file, the translated value will be returned.

for example:

    QTranslatableSettings settings;
    settings.setValue("animal/snake", 58);
    settings.value("animal/snake", 1024).toInt();   // returns 58
    settings.value("animal/zebra", 1024).toInt();   // returns 1024
    settings.value("animal/zebra").toInt();         // returns 0

See also QSettings::setValue(), contains(), and QSettings::remove().


Copyright © 2008 Nokia Trademarks
Qtopia 4.3.3