Qt
6.x
The Qt SDK
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
{
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());
43
}
44
45
void
DBus_PendingReply_Interface::PendingReplyBool
()
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
}
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::callInterfaceMainR
void callInterfaceMainR()
DBus_PendingReply_Interface::~DBus_PendingReply_Interface
~DBus_PendingReply_Interface()
Definition
src_qdbus_qdbuspendingreply.cpp:17
DBus_PendingReply_Interface::DBus_PendingReply_Interface
DBus_PendingReply_Interface(QObject *parent=nullptr)
Definition
src_qdbus_qdbuspendingreply.cpp:12
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)
QDBusAbstractInterface::asyncCall
QDBusPendingCall asyncCall(const QString &method)
Definition
qdbusabstractinterface.h:101
QDBusError
\inmodule QtDBus
Definition
qdbuserror.h:21
QDBusInterface
\inmodule QtDBus
Definition
qdbusinterface.h:18
QDBusPendingReply
\inmodule QtDBus
Definition
qdbuspendingreply.h:51
QNetworkReply::error
NetworkError error() const
Returns the error that was found during the processing of this request.
Definition
qnetworkreply.cpp:554
QObject
\inmodule QtCore
Definition
qobject.h:90
QObject::parent
QObject * parent() const
Returns a pointer to the parent object.
Definition
qobject.h:311
QVariant
\inmodule QtCore
Definition
qvariant.h:64
Q_OBJECT
#define Q_OBJECT
Definition
qtmetamacros.h:117
slots
#define slots
Definition
qtmetamacros.h:40
reply
QNetworkReply * reply
Definition
src_network_access_qhttpmultipart.cpp:26
QDBusPendingReplyTypes::Select::Type
Next::Type Type
Definition
qdbuspendingreply.h:33
qtbase
src
dbus
doc
snippets
code
src_qdbus_qdbuspendingreply.cpp
Generated by
1.9.7