QDBusPendingCallWatcher Class
The QDBusPendingCallWatcher class provides a convenient way of waiting for asynchronous replies. More…
| Header | #include <QDBusPendingCallWatcher> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::DBus) |
| Module | Nt D-Bus C++ Classes |
| Inherits | QObject, QDBusPendingCall |
List of all members, including inherited members
Public Functions
| QDBusPendingCallWatcher(const QDBusPendingCall &call, QObject *parent = nullptr) | |
| ~QDBusPendingCallWatcher() | |
| void | waitForFinished() |
Signals
| void | finished(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
QDBusPendingCallWatcher::QDBusPendingCallWatcher(const QDBusPendingCall &call, QObject *parent = nullptr)
Constructs a watcher for call with the given parent.
QDBusPendingCallWatcher::~QDBusPendingCallWatcher()
Destroys the watcher. The call goes on.
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.