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

Public Types

enum anonymous { Count }

Public Functions

QDBusPendingReply()
QDBusPendingReply(const QDBusPendingReply &other)
QDBusPendingReply(const QDBusPendingCall &call)
QDBusPendingReply(const QDBusMessage &message)
QVariant argumentAt(int index) const
int count() const
QDBusError error() const
bool isError() const
bool isFinished() const
bool isValid() const
QDBusMessage reply() const
QDBusPendingReply::T1 value() const
void waitForFinished()
QDBusPendingReply::T1 operator QDBusPendingReply::T1() const
QDBusPendingReply &operator=(const QDBusPendingReply &other)
QDBusPendingReply &operator=(const QDBusPendingCall &call)
QDBusPendingReply &operator=(const QDBusMessage &message)

Additional Inherited Members

Detailed Description

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

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::Count0The number of arguments the reply is expected to have

Member Function Documentation

QDBusPendingReply::QDBusPendingReply()

Default constructs an instance of QDBusPendingReply.

QDBusPendingReply::QDBusPendingReply(const QDBusPendingReply &other)

Default constructs an instance of QDBusPendingReply.

QDBusPendingReply::QDBusPendingReply(const QDBusPendingCall &call)

Default constructs an instance of QDBusPendingReply.

QDBusPendingReply::QDBusPendingReply(const QDBusMessage &message)

Default constructs an instance of QDBusPendingReply.

QVariant QDBusPendingReply::argumentAt(int index) const

int QDBusPendingReply::count() const

QDBusError QDBusPendingReply::error() const

bool QDBusPendingReply::isError() const

bool QDBusPendingReply::isFinished() const

bool QDBusPendingReply::isValid() const

QDBusMessage QDBusPendingReply::reply() const

QDBusPendingReply::T1 QDBusPendingReply::value() const

void QDBusPendingReply::waitForFinished()

QDBusPendingReply::T1 QDBusPendingReply::operator QDBusPendingReply::T1() const

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

Copy-assignment operator.

QDBusPendingReply &QDBusPendingReply::operator=(const QDBusPendingCall &call)

Copy-assignment operator.

QDBusPendingReply &QDBusPendingReply::operator=(const QDBusMessage &message)

Copy-assignment operator.