gpt4 book ai didi

qt - dbus 示例中名为 “car.xml” 的 “D-Bus remote controlled car example” 文件是如何生成的?

转载 作者:行者123 更新时间:2023-12-02 02:19:51 24 4
gpt4 key购买 nike

我正在尝试创建利用 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 ,不分配 name属性为<node>截至目前。如果有人希望分配 name属性,她必须自己输入,但对于 <interface>节点,可以通过放置宏 Q_CLASSINFO 让上述工具自动执行此操作。在类(class)内部,人们希望公开。

关于qt - dbus 示例中名为 “car.xml” 的 “D-Bus remote controlled car example” 文件是如何生成的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23095601/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com