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  · 

QDBusPendingCallWatcher Class Reference

The QDBusPendingCallWatcher class provides a convenient way for waiting for asynchronous replies More...

 #include <QDBusPendingCallWatcher>

Inherits: QObject and QDBusPendingCall.

This class was introduced in Qt 4.5.

Public Functions

QDBusPendingCallWatcher ( const QDBusPendingCall & call, QObject * parent = 0 )
~QDBusPendingCallWatcher ()
bool isFinished () const
void waitForFinished ()

Signals

void finished ( QDBusPendingCallWatcher * self )

Additional Inherited Members

Detailed Description

The QDBusPendingCallWatcher class provides a convenient way for waiting for asynchronous replies

The QDBusPendingCallWatcher provides the finished() signal that will be emitted when a reply arrives.

It is usually used like the following example:

     QDBusPendingCall async = iface->asyncCall("RemoteMethod", value1, value2);
     QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);

     QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
                      this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));

Note that it is not necessary to keep the original QDBusPendingCall object around since QDBusPendingCallWatcher inherits from that class too.

The slot connected to by the above code could be something similar to the following:

 void MyClass::callFinishedSlot(QDBusPendingCallWatcher *call)
 {
     QDBusPendingReply<QString, QByteArray> reply = *call;
     if (reply.isError()) {
         showError();
     } else {
         QString text = reply.argumentAt<0>();
         QByteArray data = reply.argumentAt<1>();
         showReply(text, data);
     }
     call->deleteLater();
 }

Note the use of QDBusPendingReply to validate the argument types in the reply. If the reply did not contain exactly two arguments (one string and one QByteArray), QDBusPendingReply::isError() will return true.

See also QDBusPendingReply and QDBusAbstractInterface::asyncCall().

Member Function Documentation

QDBusPendingCallWatcher::QDBusPendingCallWatcher ( const QDBusPendingCall & call, QObject * parent = 0 )

Creates a QDBusPendingCallWatcher object to watch for replies on the asynchronous pending call call and sets this object's parent to parent.

QDBusPendingCallWatcher::~QDBusPendingCallWatcher ()

Destroys this object. If this QDBusPendingCallWatcher object was the last reference to the unfinished pending call, the call will be canceled.

void QDBusPendingCallWatcher::finished ( QDBusPendingCallWatcher * self ) [signal]

This signal is emitted when the pending call has finished and its reply is available. The self parameter is a pointer to the object itself, passed for convenience so that the slot can access the properties and determine the contents of the reply.

bool QDBusPendingCallWatcher::isFinished () const

Returns true if the pending call has finished processing and the reply has been received.

Note that this function only changes state if you call waitForFinished() or if an external D-Bus event happens, which in general only happens if you return to the event loop execution.

See also QDBusPendingReply::isFinished().

void QDBusPendingCallWatcher::waitForFinished ()

Suspends the execution of the calling thread until the reply is received and processed. After this function returns, isFinished() should return true, indicating the reply's contents are ready to be processed.

See also QDBusPendingReply::waitForFinished().

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 4.8
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