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  · 

QValueSpaceItem Class Reference
[QtBaseModule]

The QValueSpaceItem class allows access to Value Space items. More...

    #include <QValueSpaceItem>

Inherits QObject.

Public Functions

  • QValueSpaceItem ( const QValueSpaceItem & base, const QByteArray & path, QObject * parent = 0 )
  • QValueSpaceItem ( const QValueSpaceItem & other, QObject * parent = 0 )
  • QValueSpaceItem ( const QByteArray & path, QObject * parent = 0 )
  • QValueSpaceItem ( QObject * parent = 0 )
  • QValueSpaceItem ( const QValueSpaceItem & base, const QString & path, QObject * parent = 0 )
  • QValueSpaceItem ( const QValueSpaceItem & base, const char * path, QObject * parent = 0 )
  • QValueSpaceItem ( const QString & path, QObject * parent = 0 )
  • QValueSpaceItem ( const char * path, QObject * parent = 0 )
  • virtual ~QValueSpaceItem ()
  • QString itemName () const
  • void remove ()
  • void remove ( const QByteArray & subPath )
  • void remove ( const char * subPath )
  • void remove ( const QString & subPath )
  • void setValue ( const QVariant & value )
  • void setValue ( const QByteArray & subPath, const QVariant & value )
  • void setValue ( const char * subPath, const QVariant & value )
  • void setValue ( const QString & subPath, const QVariant & value )
  • QList<QString> subPaths () const
  • bool sync ()
  • QVariant value ( const QByteArray & subPath = QByteArray(), const QVariant & def = QVariant() ) const
  • QVariant value ( const QString & subPath, const QVariant & def = QVariant() ) const
  • QVariant value ( const char * subPath, const QVariant & def = QVariant() ) const
  • QValueSpaceItem & operator= ( const QValueSpaceItem & other )
  • 29 public functions inherited from QObject

Signals

Additional Inherited Members

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

Detailed Description

The QValueSpaceItem class allows access to Value Space items.

The Value Space is an inter-application hierarchy of readable, writable and subscribable data. The QValueSpaceItem class allows applications to read and subscribe to this data.

Conceptually, the Value Space is a hierarchical tree of which each item can optionally contain a QVariant value and sub-items. A serialized version of a simple example might look like this.

    /Device/Buttons = 3
    /Device/Buttons/1/Name = Context
    /Device/Buttons/1/Usable = true
    /Device/Buttons/2/Name = Select
    /Device/Buttons/2/Usable = false
    /Device/Buttons/3/Name = Back
    /Device/Buttons/3/Usable = true

Any application in Qt Extended can read values from the Value Space, or be notified asynchronously when they change using the QValueSpaceItem class.

Items in the Value Space can be thought of as representing "objects" adhering to a well known schema. This is a conceptual differentiation, not a physical one, as internally the Value Space is treated as one large tree. In the sample above, the /Device/Buttons schema can be defined as containing a value representing the number of mappable buttons on a device, and a sub-item for each. Likewise, the sub-item object schema contains two attributes - Name and Usable.

Applications may use the QValueSpaceObject class to create a schema object within the Value Space. Objects remain in the Value Space as long as the QValueSpaceObject instance exists - that is, they are not persistant. If the object is destroyed, or the application containing it exits (or crashes) the items are removed.

Change notification is modelled in a similar way. Applications subscribe to notifications at a particular object (ie. item) in the tree. If anything in that object (ie. under that item) changes, the application is notified. This allows, for example, subscription to just the /Device/Buttons item to receive notification when anything "button" related changes.

For example,

    QValueSpaceItem *buttons = new QValueSpaceItem("/Device/Buttons");
    qWarning() << "There are" << buttons->value().toUInt() << "buttons";
    QObject::connect(buttons, SIGNAL(contentsChanged()),
                     this, SLOT(buttonInfoChanged()));

will invoke the buttonInfoChanged() slot whenever any item under /Device/Buttons changes. This includes the value of /Device/Buttons itself, a change of a sub-object such as /Device/Buttons/2/Name or the creation (or removal) of a new sub-object, such as /Device/Buttons/4.

Note: The QValueSpaceItem class is not thread safe and may only be used from an application's main thread.


Member Function Documentation

QValueSpaceItem::QValueSpaceItem ( const QValueSpaceItem & base, const QByteArray & path, QObject * parent = 0 )

Construct a new QValueSpaceItem with the specified parent that refers to the sub-path of base.

QValueSpaceItem::QValueSpaceItem ( const QValueSpaceItem & other, QObject * parent = 0 )

Construct a new QValueSpaceItem with the specified parent that refers to the same path as other.

QValueSpaceItem::QValueSpaceItem ( const QByteArray & path, QObject * parent = 0 )

Construct a new QValueSpaceItem with the specified parent that refers to path.

QValueSpaceItem::QValueSpaceItem ( QObject * parent = 0 )

Construct a new QValueSpaceItem with the specified parent that refers to the root path .

QValueSpaceItem::QValueSpaceItem ( const QValueSpaceItem & base, const QString & path, QObject * parent = 0 )

Construct a new QValueSpaceItem with the specified parent that refers to the sub-path of base. This constructor is equivalent to QValueSpaceItem(base, path.toUtf8()).

QValueSpaceItem::QValueSpaceItem ( const QValueSpaceItem & base, const char * path, QObject * parent = 0 )

Construct a new QValueSpaceItem with the specified parent that refers to the sub-path of base. This constructor is equivalent to QValueSpaceItem(base, QByteArray(path)).

QValueSpaceItem::QValueSpaceItem ( const QString & path, QObject * parent = 0 )

Construct a new QValueSpaceItem with the specified parent that refers to path. This constructor is equivalent to QValueSpaceItem(path.toUtf8()).

QValueSpaceItem::QValueSpaceItem ( const char * path, QObject * parent = 0 )

Construct a new QValueSpaceItem with the specified parent that refers to path. This constructor is equivalent to QValueSpaceItem(QByteArray(path)).

QValueSpaceItem::~QValueSpaceItem ()   [virtual]

Destroys the QValueSpaceItem

void QValueSpaceItem::contentsChanged ()   [signal]

Emitted whenever the value of this item, or any sub-items changes.

QString QValueSpaceItem::itemName () const

Returns the item name of this QValueSpaceItem.

void QValueSpaceItem::remove ()

Request that the item be removed. The provider of the item determines whether the request is honored or ignored.

Note: This call asynchronously asks the current provider of the object to change the value. To explicitly make a change use QValueSpaceObject.

See also QValueSpaceObject::itemRemove().

void QValueSpaceItem::remove ( const QByteArray & subPath )

This is an overloaded member function, provided for convenience.

Request that the subPath of item be removed. The provider of the sub path determines whether the request is honored or ignored.

Note: This call asynchronously asks the current provider of the object to change the value. To explicitly make a change use QValueSpaceObject.

See also QValueSpaceObject::itemRemove().

void QValueSpaceItem::remove ( const char * subPath )

This is an overloaded member function, provided for convenience.

Request that the subPath of item be removed. The provider of the sub path determines whether the request is honored or ignored.

Note: This call asynchronously asks the current provider of the object to change the value. To explicitly make a change use QValueSpaceObject.

See also QValueSpaceObject::itemRemove().

void QValueSpaceItem::remove ( const QString & subPath )

This is an overloaded member function, provided for convenience.

Request that the subPath of item be removed. The provider of the sub path determines whether the request is honored or ignored.

Note: This call asynchronously asks the current provider of the object to change the value. To explicitly make a change use QValueSpaceObject.

See also QValueSpaceObject::itemRemove().

void QValueSpaceItem::setValue ( const QVariant & value )

Request that the value of this item be changed to value. The provider of the item determines whether the request is honored or ignored.

Note: This call asynchronously asks the current provider of the object to change the value. To explicitly make a change use QValueSpaceObject.

See also value() and QValueSpaceObject::itemSetValue().

void QValueSpaceItem::setValue ( const QByteArray & subPath, const QVariant & value )

This is an overloaded member function, provided for convenience.

Request that the value of the subPath of this item be changed to value. The provider of the sub path determines whether the request is honored or ignored.

Note: This call asynchronously asks the current provider of the object to change the value. To explicitly make a change use QValueSpaceObject.

See also QValueSpaceObject::itemSetValue().

void QValueSpaceItem::setValue ( const char * subPath, const QVariant & value )

This is an overloaded member function, provided for convenience.

Request that the value of the subPath of this item be changed to value. The provider of the sub path determines whether the request is honored or ignored.

Note: This call asynchronously asks the current provider of the object to change the value. To explicitly make a change use QValueSpaceObject.

See also QValueSpaceObject::itemSetValue().

void QValueSpaceItem::setValue ( const QString & subPath, const QVariant & value )

This is an overloaded member function, provided for convenience.

Request that the value of the subPath of this item be changed to value. The provider of the sub path determines whether the request is honored or ignored.

Note: This call asynchronously asks the current provider of the object to change the value. To explicitly make a change use QValueSpaceObject.

See also QValueSpaceObject::itemSetValue().

QList<QString> QValueSpaceItem::subPaths () const

Returns a list of sub-paths for this item. For example, given a Value Space tree containing:

    /Settings/Trolltech/IniValueSpace
    /Settings/Trolltech/Other
    /Settings/Qtopia
    /Device/Buttons

QValueSpaceItem("/Settings").subPaths() will return a list containing { Trolltech, Qtopia } in no particular order.

bool QValueSpaceItem::sync ()

Commit all changes made by calls to setValue() or remove(). The return value is reserved for future use.

QVariant QValueSpaceItem::value ( const QByteArray & subPath = QByteArray(), const QVariant & def = QVariant() ) const

Returns the value of sub-item subPath of this item, or the value of this item if subPath is empty. The following code shows how the item and subPath relate.

    QValueSpaceItem base("/Settings");
    QValueSpaceItem equiv("/Settings/Trolltech/IniValueSpace/General/Mappings);

    // Is true
    equiv.value() == base.value("Trolltech/IniValueSpace/General/Mapping");

If the item does not exist, def is returned.

See also setValue().

QVariant QValueSpaceItem::value ( const QString & subPath, const QVariant & def = QVariant() ) const

This is an overloaded member function, provided for convenience.

This is a convenience overload and is equivalent to value(subPath.toUtf8(), def).

QVariant QValueSpaceItem::value ( const char * subPath, const QVariant & def = QVariant() ) const

This is an overloaded member function, provided for convenience.

This is a convenience overload and is equivalent to value(QByteArray(subPath), def).

QValueSpaceItem & QValueSpaceItem::operator= ( const QValueSpaceItem & other )

Assign other to this.

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 103
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 56
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 90
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 31
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 231
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 103
  7. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
Page suivante

Le Qt Developer Network au hasard

Logo

Comment fermer une application

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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