blob: 2def08bdfe9dd9204d92b5b70906ebfc75482fbb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QDBusPendingCall>
#include <QDBusInterface>
#include <QDBusPendingReply>
#include <QDBusReply>
class DBus_Process_String_Interface : public QObject
{
Q_OBJECT
public:
DBus_Process_String_Interface(QObject *parent = nullptr)
: QObject(parent) {
interface = new QDBusInterface("org.example.Interface", "/Example/Methods");
}
~DBus_Process_String_Interface() { delete interface; }
void QDBus_reply();
void useValue(QVariant);
void showError(const QDBusError&);
public slots:
private:
QDBusInterface *interface;
};
void DBus_Process_String_Interface::QDBus_reply()
{
//! [0]
QDBusReply<QString> reply = interface->call("RemoteMethod");
if (reply.isValid())
// use the returned value
useValue(reply.value());
else
// call failed. Show an error condition.
showError(reply.error());
//! [0]
//! [1]
reply = interface->call("RemoteMethod");
//! [1]
}
|