Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
src_qdbus_qdbuspendingreply.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3#include <QDBusPendingCall>
4#include <QDBusInterface>
5#include <QDBusPendingReply>
6
8{
10
11public:
13 : QObject(parent) {
14 iface = new QDBusInterface("org.example.Interface", "/Example/Methods");
15 }
16
17 ~DBus_PendingReply_Interface() { delete iface; }
19 void PendingReplyString();
20 void PendingReplyBool();
25public slots:
26
27private:
28 QDBusInterface *iface;
29};
30
32{
34 QDBusPendingReply<QString> reply = iface->asyncCall("RemoteMethod");
35 reply.waitForFinished();
36 if (reply.isError())
37 // call failed. Show an error condition.
39 else
40 // use the returned value
41 useValue(reply.value());
43}
44
46{
48 QDBusPendingReply<bool, QString> reply = iface->asyncCall("RemoteMethod");
49 reply.waitForFinished();
50 if (!reply.isError()) {
51 if (reply.argumentAt<0>())
52 showSuccess(reply.argumentAt<1>());
53 else
54 showFailure(reply.argumentAt<1>());
55 }
57}
void showErrorD(QDBusError)
DBus_PendingReply_Interface(QObject *parent=nullptr)
void useValue(QDBusPendingReplyTypes::Select< 0, QString, void, void, void, void, void, void, void >::Type)
QDBusPendingCall asyncCall(const QString &method)
\inmodule QtDBus
Definition qdbuserror.h:21
\inmodule QtDBus
NetworkError error() const
Returns the error that was found during the processing of this request.
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
\inmodule QtCore
Definition qvariant.h:65
#define Q_OBJECT
#define slots
QNetworkReply * reply