QDBusPendingReply Class

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 }

Additional Inherited Members

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:

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, QDBusReply, and QDBusAbstractInterface::asyncCall().

Member Type Documentation

enum QDBusPendingReply::anonymous

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