|  | Home · All Classes · Modules

# QDBusMessage Class Reference
[QtDBus module]

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

### Types

- enum MessageType { InvalidMessage, MethodCallMessage, ReplyMessage, ErrorMessage, SignalMessage }

### Methods

- __init__ (self)
- __init__ (self, QDBusMessage other)
- list-of-QVariant arguments (self)
- bool autoStartService (self)
- QDBusMessage createErrorReply (self, QString name, QString msg)
- QDBusMessage createErrorReply (self, QDBusError error)
- QDBusMessage createErrorReply (self, QDBusError.ErrorType type, QString msg)
- QDBusMessage createReply (self, list-of-QVariant arguments = QList<QVariant>())
- QDBusMessage createReply (self, QVariant argument)
- QString errorMessage (self)
- QString errorName (self)
- QString interface (self)
- bool isDelayedReply (self)
- bool isReplyRequired (self)
- QString member (self)
- QString path (self)
- QString service (self)
- setArguments (self, list-of-QVariant arguments)
- setAutoStartService (self, bool enable)
- setDelayedReply (self, bool enable)
- QString signature (self)
- MessageType type (self)

### Static Methods

- QDBusMessage createError (QString name, QString msg)
- QDBusMessage createError (QDBusError error)
- QDBusMessage createError (QDBusError.ErrorType type, QString msg)
- QDBusMessage createMethodCall (QString service, QString path, QString interface, QString method)
- QDBusMessage createSignal (QString path, QString interface, QString name)

### Special Methods

- QDBusMessage __lshift__ (self, QVariant arg)

## Detailed Description

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

This object can represent any of the four different types of messages (MessageType) that can occur on the bus:

- Method calls
- Method return values
- Signal emissions
- Error codes

Objects of this type are created with the static createError(), createMethodCall() and createSignal() functions. Use the QDBusConnection.send() function to send the messages.

## Type Documentation

### QDBusMessage.MessageType

The possible message types:

Constant | Value | Description
--- | --- | ---
`QDBusMessage.MethodCallMessage` | `1` | a message representing an outgoing or incoming method call
`QDBusMessage.SignalMessage` | `4` | a message representing an outgoing or incoming signal emission
`QDBusMessage.ReplyMessage` | `2` | a message representing the return values of a method call
`QDBusMessage.ErrorMessage` | `3` | a message representing an error condition in response to a method call
`QDBusMessage.InvalidMessage` | `0` | an invalid message: this is never set on messages received from D-Bus

## Method Documentation

### QDBusMessage.__init__ (self)

Constructs an empty, invalid QDBusMessage object.

See also createError(), createMethodCall(), and createSignal().

### QDBusMessage.__init__ (self, QDBusMessage other)

Constructs a copy of the object given by other.

Note: QDBusMessage objects are shared. Modifications made to the copy will affect the original one as well. See setDelayedReply() for more information.

### list-of-QVariant QDBusMessage.arguments (self)

Returns the list of arguments that are going to be sent or were received from D-Bus.

See also setArguments().

### bool QDBusMessage.autoStartService (self)

Returns the auto start flag, as set by setAutoStartService(). By default, this flag is true, which means QtDBus will auto start a service, if it is not running already.

This function was introduced in Qt 4.7.

See also setAutoStartService().

### QDBusMessage QDBusMessage.createError (QString name, QString msg)

Constructs a new DBus message representing an error, with the given name and msg.

### QDBusMessage QDBusMessage.createError (QDBusError error)

Constructs a new DBus message representing the given error.

### QDBusMessage QDBusMessage.createError (QDBusError.ErrorType type, QString msg)

Constructs a new DBus message for the error type type using the message msg. Returns the DBus message.

### QDBusMessage QDBusMessage.createErrorReply (self, QString name, QString msg)

Constructs a new DBus message representing an error reply message, with the given name and msg.

### QDBusMessage QDBusMessage.createErrorReply (self, QDBusError error)

Constructs a new DBus message representing an error reply message, from the given error object.

### QDBusMessage QDBusMessage.createErrorReply (self, QDBusError.ErrorType type, QString msg)

Constructs a new DBus reply message for the error type type using the message msg. Returns the DBus message.

### QDBusMessage QDBusMessage.createMethodCall (QString service, QString path, QString interface, QString method)

Constructs a new DBus message representing a method call. A method call always informs its destination address (service, path, interface and method).

The DBus bus allows calling a method on a given remote object without specifying the destination interface, if the method name is unique. However, if two interfaces on the remote object export the same method name, the result is undefined (one of the two may be called or an error may be returned).

When using DBus in a peer-to-peer context (i.e., not on a bus), the service parameter is optional.

The QDBusObject and QDBusInterface classes provide a simpler abstraction to synchronous method calling.

This function returns a QDBusMessage object that can be sent with QDBusConnection.call().

### QDBusMessage QDBusMessage.createReply (self, list-of-QVariant arguments = QList<QVariant>())

Constructs a new DBus message representing a reply, with the given arguments.

### QDBusMessage QDBusMessage.createReply (self, QVariant argument)

Constructs a new DBus message representing a reply, with the given argument.

### QDBusMessage QDBusMessage.createSignal (QString path, QString interface, QString name)

Constructs a new DBus message with the given path, interface and name, representing a signal emission.

A DBus signal is emitted from one application and is received by all applications that are listening for that signal from that interface.

The QDBusMessage object that is returned can be sent using the QDBusConnection.send() function.

### QString QDBusMessage.errorMessage (self)

Returns the human-readable message associated with the error that was received.

This function was introduced in Qt 4.3.

### QString QDBusMessage.errorName (self)

Returns the name of the error that was received.

### QString QDBusMessage.interface (self)

Returns the interface of the method being called (in the case of a method call) or of the signal being received from.

### bool QDBusMessage.isDelayedReply (self)

Returns the delayed reply flag, as set by setDelayedReply(). By default, this flag is false, which means QtDBus will generate automatic replies when necessary.

### bool QDBusMessage.isReplyRequired (self)

Returns the flag that indicates if this message should see a reply or not. This is only meaningful for method call messages: any other kind of message cannot have replies and this function will always return false for them.

### QString QDBusMessage.member (self)

Returns the name of the signal that was emitted or the name of the method that was called.

### QString QDBusMessage.path (self)

### QString QDBusMessage.service (self)

Returns the name of the service or the bus address of the remote method call.

### QDBusMessage.setArguments (self, list-of-QVariant arguments)

Sets the arguments that are going to be sent over D-Bus to arguments. Those will be the arguments to a method call or the parameters in the signal.

See also arguments().

### QDBusMessage.setAutoStartService (self, bool enable)

Sets the auto start flag to enable. This flag only makes sense for method call messages, where it tells the D-Bus server to either auto start the service responsible for the service name, or not to auto start it.

By default this flag is true, i.e. a service is autostarted. This means:

When the service that this method call is sent to is already running, the method call is sent to it. If the service is not running yet, the D-Bus daemon is requested to autostart the service that is assigned to this service name. This is handled by .service files that are placed in a directory known to the D-Bus server. These files then each contain a service name and the path to a program that should be executed when this service name is requested.

This function was introduced in Qt 4.7.

See also autoStartService().

### QDBusMessage.setDelayedReply (self, bool enable)

Sets whether the message will be replied later (if enable is true) or if an automatic reply should be generated by QtDBus (if enable is false).

In D-Bus, all method calls must generate a reply to the caller, unless the caller explicitly indicates otherwise (see isReplyRequired()). QtDBus automatically generates such replies for any slots being called, but it also allows slots to indicate whether they will take responsibility of sending the reply at a later time, after the function has finished processing.

See also isDelayedReply() and Delayed Replies.

### QString QDBusMessage.signature (self)

Returns the signature of the signal that was received or for the output arguments of a method call.

### MessageType QDBusMessage.type (self)

Returns the message type.

### QDBusMessage QDBusMessage.__lshift__ (self, QVariant arg)