c++ - Qt DBus : register object that implements multiple interfaces

标签 c++ qt dbus multiple-interface-implem

使用 Qt DBus 库,我很难注册实现多个接口(interface)的对象。

<node> 
  <interface name="x.I1"> <method name="foo"/> </interface>
  <interface name="x.I2"> <method name="bar"/> </interface>
</node>

我使用 C++ 多重继承实现了这两个接口(interface)。

class Impl : public x.I1, public x.I2 {
public:
   void foo(){}
   void bar(){}
};

qdbusxml2cpp 工具为每个接口(interface)生成一个 DBusAdaptor,但是 QDBusConnection 没有添加接口(interface)的方法该对象的实现者。

我想在 DBus 服务上发布这个对象。

QDBusConnection conn=QDBusConnection::sessionBus();
conn.registerObject("/obj",new DBusAdaptor????(&myObject) );

必须实现我自己的适配器来实现这个吗?

最佳答案

不能继承2个QDBusAbstractAdaptor类,因为它们本身继承自不支持多重继承的QObject,以及QtDBus Adaptor documentation :

The class must also contain one Q_CLASSINFO entry with the "D-Bus Interface" name, declaring which interface it is exporting. Only one entry per class is supported.

因此您不能自己实现一个支持多个接口(interface)的适配器。

关于c++ - Qt DBus : register object that implements multiple interfaces,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9768414/

相关文章:

C++ 添加 1 年至今

c++ - luabind::object 取消引用的问题(简化)

C++ 输入输出排序

c++ - 无法使用任何 QWebSocket 客户端基本示例

linux - 检测 D-Bus 上的禁止关闭

C++ 复项多项式函数评估失败

c++ - 打开外部应用程序并关闭当前应用程序

c++ - qt 和 libbluedevil : No Such slot

Python+D-Bus+BlueZ 5 : can't read property of object?

c++ - 如何用qdbusxml2cpp生成同步接口(interface)类?