本页面

qt_add_dbus_interfaces

生成实现 D-Bus 接口描述文件中接口的 C++ 源代码。

该命令定义在Qt6 软件包的DBus 组件中。使用以下命令加载该软件包:

find_package(Qt6 REQUIRED COMPONENTS DBus)

该命令于 Qt 6.0 版本中引入。

语法

qt_add_dbus_interfaces(<VAR> dbus_spec1 [dbus_spec2 ...])

如果禁用了无版本号的命令,请改用 `qt6_add_dbus_interfaces() `。它支持与本命令相同的参数集。

描述

生成实现dbus_spec1 和dbus_spec2 中定义的 D-Bus 接口的 C++ 源代码,其中每个参数必须是有效 D-Bus 接口描述文件的路径。生成的文件路径将被添加到<VAR> 中。

对于每个参数,都会设置一次以接口(代理)模式调用Qt D-Bus XML 编译器(qdbusxml2cpp)的操作。

生成的 C++ 源文件以 XML 文件命名:例如,对于文件org.example.chat.xml ,生成的头文件将命名为orgexamplechatinterface.h 。

选项

可通过set_source_files_properties 对每个文件参数设置选项:

选项值说明
CLASSNAMEclass_name使用class_name 覆盖默认接口类名。
NO_NAMESPACE布尔值如果设置为ON ,则不生成带命名空间的名称。
INCLUDEpath在生成的代码中添加一个#include "path" 。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.