Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
7
class
DBus_PendingCall_Interface
:
public
QObject
8
{
9
Q_OBJECT
10
11
public
:
12
DBus_PendingCall_Interface
(
QObject
*
parent
=
nullptr
)
13
:
QObject
(
parent
) {
14
iface
=
new
QDBusInterface
(
"org.example.Interface"
,
"/Example/Methods"
);
15
}
16
17
~
DBus_PendingCall_Interface
() {
delete
iface
; }
18
void
callInterfaceMain
();
19
void
showError
();
20
void
showReply
(QString&, QByteArray&);
21
QString
value1
;
22
QString
value2
;
23
void
callFinishedSlot
(QDBusPendingCallWatcher *call);
24
public
slots
:
25
26
private
:
27
QDBusInterface
*
iface
;
28
};
29
30
void
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]
43
void
DBus_PendingCall_Interface
::
callFinishedSlot
(QDBusPendingCallWatcher *call)
44
{
45
QDBusPendingReply<QString, QByteArray> reply = *call;
46
if
(reply.isError()) {
47
showError
(
)
;
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]
DBus_PendingCall_Interface
Definition
src_qdbus_qdbuspendingcall.cpp:8
DBus_PendingCall_Interface::showError
void showError()
DBus_PendingCall_Interface::value1
QString value1
Definition
src_qdbus_qdbuspendingcall.cpp:21
DBus_PendingCall_Interface::callFinishedSlot
void callFinishedSlot(QDBusPendingCallWatcher *call)
[1]
Definition
src_qdbus_qdbuspendingcall.cpp:43
DBus_PendingCall_Interface::showReply
void showReply(QString &, QByteArray &)
DBus_PendingCall_Interface::value2
QString value2
Definition
src_qdbus_qdbuspendingcall.cpp:22
qtbase
src
dbus
doc
snippets
code
src_qdbus_qdbuspendingcall.cpp
Generated on
for Qt by
1.18.0