qt_add_dbus_interface

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

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

find_package(Qt6 REQUIRED COMPONENTS DBus)

该命令在 Qt 6.0 中引入。

简介

qt_add_dbus_interface(<VAR> dbus_spec basename)

如果禁用了无版本命令,请使用qt6_add_dbus_interface() 代替。它支持与此命令相同的参数集。

说明

dbus_spec 中定义的 D-Bus 接口描述文件生成实现接口的 C++ 源代码。生成的文件以basename 命名:basename.h,basename.cpp,basename.moc 。文件路径将添加到<VAR> 中。

该函数以接口(代理)模式调用Qt D-Bus XML 编译器 (qdbusxml2cpp)。默认情况下,qdbusxml2cpp 会生成一个以接口名称命名的 C++ 类,并带有一个命名别名:

D-Bus 接口名称类名命名别名
org.example.chatOrgExampleChatInterfaceorg.example.chat

选项

可使用set_source_files_propertiesdbus_spec 上设置选项:

选项说明
CLASSNAMEclass_nameclass_name 覆盖默认接口类名。
NO_NAMESPACE布尔如果设置为ON ,则不生成命名名称。
INCLUDEpath在生成的代码中添加#include "path"

© 2025 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.