From 05b60631a2cb5c5536490509ed5d41c08a967dc5 Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Thu, 28 May 2020 15:03:37 +0200 Subject: Doc: Make dbus snippets compilable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-84470 Change-Id: Idfe86ae0f38e43678cc5e746e30e5eeaf8eb72dc Reviewed-by: Topi Reiniƶ Reviewed-by: Nico Vertriest --- .../snippets/code/src_qdbus_qdbuspendingcall.cpp | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/dbus/doc/snippets/code/src_qdbus_qdbuspendingcall.cpp') diff --git a/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingcall.cpp b/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingcall.cpp index 9552054a5e..d75a19b62f 100644 --- a/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingcall.cpp +++ b/src/dbus/doc/snippets/code/src_qdbus_qdbuspendingcall.cpp @@ -47,7 +47,34 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +#include +#include +#include +class DBus_PendingCall_Interface : public QObject +{ + Q_OBJECT + +public: + DBus_PendingCall_Interface(QObject *parent = nullptr) + : QObject(parent) { + iface = new QDBusInterface("org.example.Interface", "/Example/Methods"); + } + + ~DBus_PendingCall_Interface() { delete iface; } + void callInterfaceMain(); + void showError(); + void showReply(QString&, QByteArray&); + QString value1; + QString value2; + void callFinishedSlot(QDBusPendingCallWatcher *call); +public slots: + +private: + QDBusInterface *iface; +}; + +void DBus_PendingCall_Interface::callInterfaceMain() { //! [0] QDBusPendingCall async = iface->asyncCall("RemoteMethod", value1, value2); @@ -60,7 +87,7 @@ } //! [1] -void MyClass::callFinishedSlot(QDBusPendingCallWatcher *call) +void DBus_PendingCall_Interface::callFinishedSlot(QDBusPendingCallWatcher *call) { QDBusPendingReply reply = *call; if (reply.isError()) { -- cgit v1.2.3