QDBusReply Class
template <typename T> class QDBusReply
The QDBusReply class stores the reply for a method call to a remote object. More…
| Header | #include <QDBusReply> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::DBus) |
| Module | Nt D-Bus C++ Classes |
List of all members, including inherited members
Public Functions
| QDBusReply(const QDBusMessage &reply) | |
| QDBusReply(const QDBusPendingCall &call) | |
| QDBusReply(const QDBusError &error = QDBusError()) | |
| QDBusReply & | operator=(const QDBusMessage &reply) |
| QDBusReply & | operator=(const QDBusPendingCall &call) |
| QDBusReply & | operator=(const QDBusError &error) |
| bool | isValid() const |
| const QDBusError & | error() const |
| T | value() const |
| operator T() const |
Detailed Description
It holds either the first argument of the reply, converted to T, or the error:
QDBusReply<int> reply = iface.call("Count");
if (reply.isValid())
qDebug() << reply.value();
else
qWarning() << reply.error().message();
QDBusReply<void> holds only an error. QDBusReply<QVariant> takes the value out of the D-Bus variant that carries it.
See also QDBusMessage and QDBusPendingReply.
Differences from Qt
None.
Member Function Documentation
QDBusReply::QDBusReply(const QDBusMessage &reply)
Constructs a reply from the message reply.
QDBusReply::QDBusReply(const QDBusPendingCall &call)
Constructs a reply from call, waiting for the call to finish.
QDBusReply::QDBusReply(const QDBusError &error = QDBusError())
Constructs a reply that holds the error error.
const QDBusError & QDBusReply::error() const
Returns the error, which is invalid if the call succeeded.
bool QDBusReply::isValid() const
Returns true if the reply holds a value rather than an error.
QDBusReply::operator T() const
Returns the value, or a default-constructed one if the call failed.
QDBusReply & QDBusReply::operator=(const QDBusMessage &reply)
Extracts the value from reply and returns a reference to this object.
QDBusReply & QDBusReply::operator=(const QDBusPendingCall &call)
Waits for call and extracts its value. Returns a reference to this object.
QDBusReply & QDBusReply::operator=(const QDBusError &error)
Makes this object hold error. Returns a reference to this object.
T QDBusReply::value() const
Returns the value, or a default-constructed one if the call failed.