在 D-Bus 适配器中声明信号

QDBusAbstractAdaptor 派生的类中的任何信号都将自动中继到 D-Bus 中,前提是信号的参数符合特定规则(更多信息请参阅 Qt D-Bus 类型系统)。这种中继无需特殊代码。

不过,信号仍然必须被发出。发射适配器信号的最简单方法是将另一个信号连接到它,这样 Qt 的信号和插槽机制也会自动发射适配器信号。这可以在适配器的构造函数中实现,如D-Bus Complex Ping Pong示例所示。

QDBusAbstractAdaptor::setAutoRelaySignals() 方便函数也可用于建立或中断真实对象中的信号与适配器中相应信号之间的连接。它将检查两个类中的信号列表,并连接参数完全匹配的信号。

另请参阅 使用Qt D-Bus 适配器在 D-Bus 适配器中声明插槽 Qt D-Bus 类型系统QDBusAbstractAdaptor

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