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_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
7
class
DBus_PendingReply_Interface
:
public
QObject
8
{
9
Q_OBJECT
10
11
public
:
12
DBus_PendingReply_Interface
(
QObject
*
parent
=
nullptr
)
13
:
QObject
(
parent
) {
14
iface
=
new
QDBusInterface
(
"org.example.Interface"
,
"/Example/Methods"
);
15
}
16
17
~
DBus_PendingReply_Interface
() {
delete
iface
; }
18
void
callInterfaceMainR
();
19
void
PendingReplyString
();
20
void
PendingReplyBool
();
21
void
showErrorD
(
QDBusError
);
22
void
showSuccess
(
QVariant
);
23
void
showFailure
(
QVariant
);
24
void
useValue
(QDBusPendingReplyTypes::Select<0, QString,
void
,
void
,
void
,
void
,
void
,
void
,
void
>::Type);
25
public
slots
:
26
27
private
:
28
QDBusInterface
*
iface
;
29
};
30
31
void
DBus_PendingReply_Interface
::
PendingReplyString
()
32
{
33
//! [0]
34
QDBusPendingReply<QString> reply = iface->asyncCall(
"RemoteMethod"
);
35
reply.waitForFinished();
36
if
(reply.isError())
37
// call failed. Show an error condition.
38
showErrorD(reply.error());
39
else
40
// use the returned value
41
useValue(reply.value());
42
//! [0]
43
}
44
45
void
DBus_PendingReply_Interface
::
PendingReplyBool
()
46
{
47
//! [2]
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
}
56
//! [2]
57
}
DBus_PendingReply_Interface
Definition
src_qdbus_qdbuspendingreply.cpp:8
DBus_PendingReply_Interface::showErrorD
void showErrorD(QDBusError)
DBus_PendingReply_Interface::PendingReplyBool
void PendingReplyBool()
Definition
src_qdbus_qdbuspendingreply.cpp:45
DBus_PendingReply_Interface::showSuccess
void showSuccess(QVariant)
DBus_PendingReply_Interface::showFailure
void showFailure(QVariant)
DBus_PendingReply_Interface::PendingReplyString
void PendingReplyString()
Definition
src_qdbus_qdbuspendingreply.cpp:31
DBus_PendingReply_Interface::useValue
void useValue(QDBusPendingReplyTypes::Select< 0, QString, void, void, void, void, void, void, void >::Type)
qtbase
src
dbus
doc
snippets
code
src_qdbus_qdbuspendingreply.cpp
Generated on
for Qt by
1.14.0