6.0.0Source

QDBusPendingCallWatcher Class

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

Header#include <QDBusPendingCallWatcher>
CMaketarget_link_libraries(app PRIVATE Nt::DBus)
ModuleNt D-Bus C++ Classes
InheritsQObject, QDBusPendingCall

List of all members, including inherited members

Public Functions

Signals

voidfinished(QDBusPendingCallWatcher *self = nullptr)

Detailed Description

The watcher emits finished() in its own thread when the call has finished:

auto *watcher = new QDBusPendingCallWatcher(iface.asyncCall("Now"), this);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [](QDBusPendingCallWatcher *w) {
    QDBusPendingReply<QString> reply = *w;
    if (!reply.isError())
        qDebug() << reply.value();
    w->deleteLater();
});

If the call has already finished, finished() is still emitted from the event loop.

See also QDBusPendingCall and QDBusPendingReply.

Differences from Qt

None.

Member Function Documentation

[explicit] QDBusPendingCallWatcher::QDBusPendingCallWatcher(const QDBusPendingCall &call, QObject *parent = nullptr)

Constructs a watcher for call with the given parent.

[override] QDBusPendingCallWatcher::~QDBusPendingCallWatcher()

Destroys the watcher. The call goes on.

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

This signal is emitted when the call has finished, with this object as self.

void QDBusPendingCallWatcher::waitForFinished()

Blocks until the call has finished. finished() is still emitted from the event loop.