QDBusInterface Class
The QDBusInterface class is a proxy for interfaces on remote objects. More...
| Header: | #include <QDBusInterface> |
| qmake: | QT += dbus |
| Since: | Qt 4.2 |
| Inherits: | QDBusAbstractInterface |
This class was introduced in Qt 4.2.
Detailed Description
QDBusInterface is a generic accessor class that is used to place calls to remote objects, connect to signals exported by remote objects and get/set the value of remote properties. This class is useful for dynamic access to remote objects: that is, when you do not have a generated code that represents the remote interface.
Calls are usually placed by using the call() function, which constructs the message, sends it over the bus, waits for the reply and decodes the reply. Signals are connected to by using the normal QObject::connect() function. Finally, properties are accessed using the QObject::property() and QObject::setProperty() functions.
The following code snippet demonstrates how to perform a mathematical operation of "2 + 2" in a remote application called com.example.Calculator, accessed via the session bus.
QDBusInterface remoteApp( "com.example.Calculator", "/Calculator/Operations", "org.mathematics.RPNCalculator" ); remoteApp.call( "PushOperand", 2 ); remoteApp.call( "PushOperand", 2 ); remoteApp.call( "ExecuteOperation", "+" ); QDBusReply<int> reply = remoteApp.call( "PopOperand" ); if ( reply.isValid() ) printf( "%d", reply.value() ); // prints 4
See also Qt D-Bus XML compiler (qdbusxml2cpp).