QDBusPendingReply Class

template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8> class QDBusPendingReply

The QDBusPendingReply class contains the reply to an asynchronous method call. More...

Header: #include <QDBusPendingReply>
qmake: QT += dbus
Since: Qt 4.5
Inherits: QDBusPendingCall

This class was introduced in Qt 4.5.

Public Types

enum anonymous { Count }

Detailed Description

The QDBusPendingReply is a template class with up to 8 template parameters. Those parameters are the types that will be used to extract the contents of the reply's data.

This class is similar in functionality to QDBusReply, but with two important differences:

  • QDBusReply accepts exactly one return type, whereas QDBusPendingReply can have from 1 to 8 types
  • QDBusReply only works on already completed replies, whereas QDBusPendingReply allows one to wait for replies from pending calls

Where with QDBusReply you would write:

 QDBusReply<QString> reply = interface->call("RemoteMethod");
 if (reply.isValid())
     // use the returned value
     useValue(reply.value());
 else
     // call failed. Show an error condition.
     showError(reply.error());

with QDBusPendingReply, the equivalent code (including the blocking wait for the reply) would be:

     QDBusPendingReply<QString> reply = interface->asyncCall("RemoteMethod");
     reply.waitForFinished();
     if (reply.isError())
         // call failed. Show an error condition.
         showError(reply.error());
     else
         // use the returned value
         useValue(reply.value());

For method calls that have more than one output argument, with QDBusReply, you would write:

 QString reply = interface->call("RemoteMethod");

whereas with QDBusPendingReply, all of the output arguments should be template parameters:

     QDBusPendingReply<bool, QString> reply = interface->asyncCall("RemoteMethod");
     reply.waitForFinished();
     if (!reply.isError()) {
         if (reply.argumentAt<0>())
             showSuccess(reply.argumentAt<1>());
         else
             showFailure(reply.argumentAt<1>());
     }

QDBusPendingReply objects can be associated with QDBusPendingCallWatcher objects, which emit signals when the reply arrives.

See also QDBusPendingCallWatcher and QDBusReply.

Member Type Documentation

enum QDBusPendingReply::anonymous

ConstantValueDescription
QDBusPendingReply::CountForEach::TotalThe number of arguments the reply is expected to have