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  · 

QValueSpaceSubscriber Class Reference

The QValueSpaceSubscriber class allows applications to read and subscribe to Value Space paths. More...

 #include <QValueSpaceSubscriber>

Inherits QObject.

Properties

  • 1 property inherited from QObject

Public Functions

QValueSpaceSubscriber ( QObject * parent = 0 )
QValueSpaceSubscriber ( const QString & path, QObject * parent = 0 )
QValueSpaceSubscriber ( QValueSpace::LayerOptions filter, const QString & path, QObject * parent = 0 )
QValueSpaceSubscriber ( const QUuid & uuid, const QString & path, QObject * parent = 0 )
virtual ~QValueSpaceSubscriber ()
void cd ( const QString & path )
void cdUp ()
bool isConnected () const
QString path () const
void setPath ( const QString & path )
void setPath ( QValueSpaceSubscriber * subscriber )
QStringList subPaths () const
QVariant value ( const QString & subPath = QString(), const QVariant & def = QVariant() ) const
  • 29 public functions inherited from QObject

Signals

void contentsChanged ()

Additional Inherited Members

  • 1 public slot inherited from QObject
  • 1 public variable 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 QValueSpaceSubscriber class allows applications to read and subscribe to Value Space paths.

By default QValueSpaceSubscriber can read values from and report change notifications for all available Value Space layers. Only data from the layer with the highest order and that contains the specific key is returned by this class.

The layers that QValueSpaceSubscriber accesses can be limited by specifying either a filter or a QUuid at construction time.

Applications subscribe to a particular path in the Value Space. If anything under that path changes the contextChanged() signal is emitted. For example given the schema:

 /Device/Buttons = 3
 /Device/Buttons/1/Name = Menu
 /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

The code:

     QValueSpaceSubscriber *buttons = new QValueSpaceSubscriber("/Device/Buttons");
     QObject::connect(buttons, SIGNAL(contentsChanged()), this, SLOT(buttonInfoChanged()));

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

Property Documentation

path : QString

This property holds the current path that the QValueSpaceSubscriber refers to.

Settings this property causes the QValueSpaceSubscriber to disconnect and reconnect to the Value Space with the new path. As a result all signal/slot connections are disconnected.

Access functions:

QString path () const
void setPath ( const QString & path )
void setPath ( QValueSpaceSubscriber * subscriber )

value : const QVariant

This property holds the value of the path that this QValueSpaceSubscriber refers to.

Notifier signal:

void contentsChanged ()

Member Function Documentation

QValueSpaceSubscriber::QValueSpaceSubscriber ( QObject * parent = 0 )

Constructs a QValueSpaceSubscriber with the specified parent that refers to the root path.

The constructed Value Space subscriber will access all available QAbstractValueSpaceLayer layers.

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

Constructs a QValueSpaceSubscriber with the specified parent that refers to path.

The constructed Value Space subscriber will access all available QAbstractValueSpaceLayer layers.

QValueSpaceSubscriber::QValueSpaceSubscriber ( QValueSpace::LayerOptions filter, const QString & path, QObject * parent = 0 )

Constructs a QValueSpaceSubscriber with the specified parent that refers to path. The filter parameter is used to limit which layers this QValueSpaceSubscriber will access.

If a layer matching filter is not found, the constructed QValueSpaceSubscriber will be unconnected.

See also isConnected().

QValueSpaceSubscriber::QValueSpaceSubscriber ( const QUuid & uuid, const QString & path, QObject * parent = 0 )

Constructs a QValueSpaceSubscriber with the specified parent that refers to path. This QValueSpaceSubscriber will only use the layer identified by uuid.

Use of this constructor is not platform agnostic. If possible use one of the constructors that take a QAbstractValueSpaceLayer::LayerOptions parameter instead.

If a layer with a matching uuid is not found, the constructed QValueSpaceSubscriber will be unconnected.

See also QAbstractValueSpaceLayer::id(), QValueSpace, and isConnected().

QValueSpaceSubscriber::~QValueSpaceSubscriber () [virtual]

Destroys the QValueSpaceSubscriber.

void QValueSpaceSubscriber::cd ( const QString & path )

Changes the path to the absolute path if path starts with a '/'; otherwise changes to the sub path of the current path.

void QValueSpaceSubscriber::cdUp ()

Sets the path to parent of the current path.

void QValueSpaceSubscriber::contentsChanged () [signal]

Emitted whenever any value under the current path changes.

Note: that if a value changes multiple times in quick succession, only the most recent value may be accessible via the value() function.

bool QValueSpaceSubscriber::isConnected () const

Returns true if this QValueSpaceSubscriber is connected to at least one available layer; otherwise returns false. An unconnected QValueSpaceSubscriber is constructed if the filtering parameters passed to the constructor eliminate all available layers.

QStringList QValueSpaceSubscriber::subPaths () const

Returns a list of sub-paths under the current path. For example, given a Value Space tree containing:

 /Settings/Nokia/Device
 /Settings/Nokia/Other
 /Settings/Qt
 /Device/Buttons

QValueSpaceSubscriber("/Settings").subPaths() will return a list containing { Nokia, Qt } in no particular order.

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

Returns the value of the subPath under this subscriber path, or the value of this subscriber path if subPath is empty. If the value does not exists def is returned.

The following code shows how the subscriber path and subPath relate.

 QValueSpaceSubscriber base("/Settings");
 QValueSpaceSubscriber equiv("/Settings/Nokia/General/Mappings");

 // Is true
 equiv.value() == base.value("Nokia/General/Mappings");
X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();
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 64
  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. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Developer Network au hasard

Logo

Combiner licence, à propos et fermer

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 qtmobility-1.1
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