加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

qt – 如何生成dbus示例中名为“D-Bus遥控车示例”的“car.xml”

发布时间:2020-12-16 22:52:27 所属栏目:百科 来源:网络整理
导读:我正在尝试创建利用D-Bus的程序.我已经研究了Qt提供的相关示例.在其中一个名为“D-Bus遥控车的例子”中有一个名为“car.xml”的文件,其中包含以下内容: !DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freede
我正在尝试创建利用D-Bus的程序.我已经研究了Qt提供的相关示例.在其中一个名为“D-Bus遥控车的例子”中有一个名为“car.xml”的文件,其中包含以下内容:

<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/com/trollech/examples/car">
 <interface name="org.example.Examples.CarInterface">
  <method name="accelerate"/>
  <method name="decelerate"/>
  <method name="turnLeft"/>
  <method name="turnRight"/>
  <signal name="crashed"/>
 </interface>
</node>

如果我没弄错的话,应该使用名为“qdbuscpp2xml”的工具生成此文件.当我使用此命令生成xml时:

$qdbuscpp2xml -A car.h -o car2.xml

我在生成的XML文件中获得以下内容:

<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="local.Car">
    <signal name="crashed">
    </signal>
    <method name="accelerate">
    </method>
    <method name="decelerate">
    </method>
    <method name="turnLeft">
    </method>
    <method name="turnRight">
    </method>
  </interface>
</node>

与以下行中的car.xml不同:

<node name="/com/trollech/examples/car">
 <interface name="org.example.Examples.CarInterface">

为什么我得到一个不同的文件?包含文件(car.xml)是否手动创建了示例?

解决方法

我自己弄清楚了.该工具即qdbuscpp2xml,没有为< node>指定名称属性.截至目前.如果希望为其分配名称属性,则必须自己键入,但是对于< interface>节点,通过将宏Q_CLASSINFO放在希望公开的类中,可以让上面提到的工具自动完成.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读