QDBusInterface Class
The QDBusInterface class is a proxy for interfaces on remote objects. 更多...
头文件: | #include <QDBusInterface> |
qmake: | QT += dbus |
开始支持版本: | Qt 4.2 |
基类: | QDBusAbstractInterface |
公有函数
QDBusInterface(const QString &service, const QString &path, const QString &interface = QString(), const QDBusConnection &connection = QDBusConnection::sessionBus(), QObject *parent = Q_NULLPTR) | |
~QDBusInterface() |
- 15 个公有函数继承自 QDBusAbstractInterface
- 32 个公有函数继承自 QObject
其他继承的成员
- 1 个属性继承自 QObject
- 1 个公有槽函数继承自 QObject
- 2 个信号继承自 QObject
- 1 个公有变量继承自 QObject
- 10 个静态公有成员继承自 QObject
- 9 个受保护的函数继承自 QObject
- 2 个受保护的变量继承自 QObject
详细描述
QDBusInterface 是一个远程对象接口的代理.
QDBusInterface 是一个通用访问器, 调用远程对象, 连接远程对象的导出信号, 获取/设置远程对象的属性值. 这个类可以动态访问远程对象, 即, 没有远程接口代码.
调用 call() 函数时, QDBusInterface构造消息, 通过总线发送消息, 等待回复, 并解码回复. 信号是采用普通的 QObject::connect() 函数连接. 调用 QObject::property() 和 QObject::setProperty() 函数访问属性.
下面的代码片段演示: 如何通过会话总线访问名称com.example.Calculator
的远程应用程序, 并执行 "2 + 2"
属性运算.
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
参见 Qt D-Bus XML compiler (qdbusxml2cpp).
成员函数
QDBusInterface::QDBusInterface(const QString &service, const QString &path, const QString &interface = QString(), const QDBusConnection &connection = QDBusConnection::sessionBus(), QObject *parent = Q_NULLPTR)
Creates a dynamic QDBusInterface object associated with the interface interface on object at path path on service service, using the given connection. If interface is an empty string, the object created will refer to the merging of all interfaces found in that object.
parent is passed to the base class constructor.
If the remote service service is not present or if an error occurs trying to obtain the description of the remote interface interface, the object created will not be valid (see isValid()).
QDBusInterface::~QDBusInterface()
Destroy the object interface and frees up any resource used.