Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QTranslatableSettings Class Reference
[QtBaseModule]

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

    #include <QTranslatableSettings>

Inherits QSettings.

Public Functions

  • 25 public functions inherited from QSettings
  • 29 public functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 1 public type inherited from QObject
  • 4 static public members inherited from QSettings
  • 4 static public members inherited from QObject
  • 7 protected functions inherited from QObject
  • 2 protected variables inherited from QObject

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:

  • Unix/X11 - fileName is the name of an INI file
  • Mac OS X - fileName is the name of a .plist file
  • Windows - fileName is a path in the system registry.

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().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 48
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 13
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le blog Digia au hasard

Logo

Une nouvelle ère d'IHM 3D pour les automobiles

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web