6.0.0-rc4Source

QDBusMessage Class

The QDBusMessage class represents one message sent or received over the D-Bus bus. More…

Header#include <QDBusMessage>
CMaketarget_link_libraries(app PRIVATE Nt::DBus)
ModuleNt D-Bus C++ Classes

List of all members, including inherited members

Public Types

Public Functions

QDBusMessage()
QDBusMessage(const QDBusMessage &other)
QDBusMessage &operator=(const QDBusMessage &other)
~QDBusMessage()
QDBusMessagecreateReply(const QList<QVariant> &arguments = QList<QVariant>()) const
QDBusMessagecreateReply(const QVariant &argument) const
QDBusMessagecreateErrorReply(const QString &name, const QString &message) const
QDBusMessagecreateErrorReply(const QDBusError &error) const
QDBusMessagecreateErrorReply(QDBusError::ErrorType type, const QString &message) const
QStringservice() const
QStringpath() const
QStringinterface() const
QStringmember() const
QStringerrorName() const
QStringerrorMessage() const
MessageTypetype() const
QStringsignature() const
boolisReplyRequired() const
voidsetDelayedReply(bool enable) const
boolisDelayedReply() const
voidsetAutoStartService(bool enable)
boolautoStartService() const
voidsetInteractiveAuthorizationAllowed(bool enable)
boolisInteractiveAuthorizationAllowed() const
voidsetArguments(const QList<QVariant> &arguments)
QList<QVariant>arguments() const
QDBusMessage &operator<<(const QVariant &argument)

Static Public Members

QDBusMessagecreateSignal(const QString &path, const QString &interface, const QString &name)
QDBusMessagecreateTargetedSignal(const QString &service, const QString &path, const QString &interface, const QString &name)
QDBusMessagecreateMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
QDBusMessagecreateError(const QString &name, const QString &message)
QDBusMessagecreateError(const QDBusError &error)
QDBusMessagecreateError(QDBusError::ErrorType type, const QString &message)

Detailed Description

A message is a method call, a reply to one, an error or a signal. Create one with the static functions, add arguments with operator<<() and send it with QDBusConnection:

QDBusMessage call = QDBusMessage::createMethodCall(
    "org.example.Clock", "/clock", "org.example.Clock", "SetAlarm");
call << 7 << 30;
QDBusMessage reply = QDBusConnection::sessionBus().call(call);
if (reply.type() == QDBusMessage::ErrorMessage)
    qWarning() << reply.errorMessage();

QDBusMessage is implicitly shared.

See also QDBusConnection and QDBusReply.

Differences from Qt

There is no QDebug stream operator and no createSignal() overload taking only a path.

Member Type Documentation

enum QDBusMessage::MessageType

The kind of a message.

ConstantDescription
QDBusMessage::InvalidMessageA message that was default-constructed or failed to parse.
QDBusMessage::MethodCallMessageA call of a method.
QDBusMessage::ReplyMessageA successful reply to a call.
QDBusMessage::ErrorMessageAn error reply to a call.
QDBusMessage::SignalMessageA signal.

Member Function Documentation

QDBusMessage::QDBusMessage()

Constructs an invalid message.

QDBusMessage::QDBusMessage(const QDBusMessage &other)

Constructs a copy of other.

QDBusMessage::~QDBusMessage()

Destroys the message.

QList<QVariant> QDBusMessage::arguments() const

Returns the arguments of the message. Containers and structures that have no C++ type are QDBusArgument values; use qdbus_cast() to extract them.

bool QDBusMessage::autoStartService() const

Returns true if the bus may start the destination service to receive this call.

[static] QDBusMessage QDBusMessage::createError(const QString &name, const QString &message)

Returns an error message with the error name and the text message.

[static] QDBusMessage QDBusMessage::createError(const QDBusError &error)

This is an overloaded function.

Returns an error message for error.

[static] QDBusMessage QDBusMessage::createError(QDBusError::ErrorType type, const QString &message)

This is an overloaded function.

Returns an error message of the type type with the text message.

QDBusMessage QDBusMessage::createErrorReply(const QString &name, const QString &message) const

Returns an error reply to this call with the error name and the text message.

QDBusMessage QDBusMessage::createErrorReply(const QDBusError &error) const

This is an overloaded function.

Returns an error reply to this call for error.

QDBusMessage QDBusMessage::createErrorReply(QDBusError::ErrorType type, const QString &message) const

This is an overloaded function.

Returns an error reply to this call of the type type with the text message.

[static] QDBusMessage QDBusMessage::createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)

Returns a call of method of interface on the object at path in destination. interface may be empty.

See also QDBusConnection::call().

QDBusMessage QDBusMessage::createReply(const QList<QVariant> &arguments = QList<QVariant>()) const

Returns a reply to this call that carries arguments.

QDBusMessage QDBusMessage::createReply(const QVariant &argument) const

This is an overloaded function.

Returns a reply to this call that carries the single argument.

[static] QDBusMessage QDBusMessage::createSignal(const QString &path, const QString &interface, const QString &name)

Returns a signal name of interface, emitted by the object at path, to every connection that listens for it.

See also createTargetedSignal() and QDBusConnection::send().

[static] QDBusMessage QDBusMessage::createTargetedSignal(const QString &service, const QString &path, const QString &interface, const QString &name)

Returns a signal name of interface, emitted by the object at path, that is sent to service only.

QString QDBusMessage::errorMessage() const

Returns the text of an error message.

QString QDBusMessage::errorName() const

Returns the name of the error of an error message.

QString QDBusMessage::interface() const

Returns the interface of a call or a signal.

bool QDBusMessage::isDelayedReply() const

Returns true if the reply to this call is to be sent later.

bool QDBusMessage::isInteractiveAuthorizationAllowed() const

Returns true if the receiver may ask the user to authorize this call.

bool QDBusMessage::isReplyRequired() const

Returns true if this is a received method call whose caller waits for a reply.

QString QDBusMessage::member() const

Returns the name of the method or signal.

QDBusMessage & QDBusMessage::operator<<(const QVariant &argument)

Appends argument to the arguments of the message and returns a reference to the message.

QDBusMessage & QDBusMessage::operator=(const QDBusMessage &other)

Makes this message a copy of other and returns a reference to it.

QString QDBusMessage::path() const

Returns the object path of a call or a signal.

QString QDBusMessage::service() const

Returns the destination of a message that is to be sent, or the unique name of the sender of a message that was received.

void QDBusMessage::setArguments(const QList<QVariant> &arguments)

Replaces the arguments of the message with arguments.

void QDBusMessage::setAutoStartService(bool enable)

Sets whether the bus may start the destination service to receive this call to enable. It is enabled by default.

void QDBusMessage::setDelayedReply(bool enable) const

Sets whether the reply to this call is sent later, by the code that handles it, to enable. Nt then sends no reply when the slot returns.

See also QDBusContext::setDelayedReply().

void QDBusMessage::setInteractiveAuthorizationAllowed(bool enable)

Sets whether the receiver may ask the user to authorize this call to enable.

QString QDBusMessage::signature() const

Returns the D-Bus signature of the arguments.

MessageType QDBusMessage::type() const

Returns the kind of the message.