QDBusPendingCallWatcher ClassThe 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
Signals
Additional Inherited Members
Detailed DescriptionThe 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
|