Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_qdbus_qdbuspendingcall.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
19 void showError();
20 void showReply(QString&, QByteArray&);
23 void callFinishedSlot(QDBusPendingCallWatcher *call);
24public slots:
25
26private:
28};
29
30void DBus_PendingCall_Interface::callInterfaceMain()
31{
32//! [0]
33 QDBusPendingCall async = iface->asyncCall("RemoteMethod", value1, value2);
34 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this);
35
36 QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this,
37 &DBus_PendingCall_Interface::callFinishedSlot);
38//! [0]
39
40}
41
42//! [1]
43void DBus_PendingCall_Interface::callFinishedSlot(QDBusPendingCallWatcher *call)
44{
45 QDBusPendingReply<QString, QByteArray> reply = *call;
46 if (reply.isError()) {
48 } else {
49 QString text = reply.argumentAt<0>();
50 QByteArray data = reply.argumentAt<1>();
51 showReply(text, data);
52 }
53 call->deleteLater();
54}
55//! [1]
void callFinishedSlot(QDBusPendingCallWatcher *call)
[1]
void showReply(QString &, QByteArray &)