变更内容Qt D-Bus
Qt 6 的变更,是出于让框架更高效、更易于使用的有意识努力。
我们力求在每个版本中保持所有公共 API 的二进制和源代码兼容性。但为了使 Qt 成为更好的框架,某些变更在所难免。
在本主题中,我们将总结 Qt DBus 中的这些变更,并提供相应的处理指南。
API 变更
QtDBus 模块已经过一些基础性的整合和清理。切换到 Qt 6 所需的移植工作量应该很小。
QDBusMessage 类
Qt6 中已移除了具有固定参数大小的 QDBusMessage::call() 和 QDBusMessage::asyncCall() 方法。
QDBusArgument 类
针对QHash 、QMap 和QList 的 QDBusArgument::operator<<() 特化形式,现已统一为适用于关联容器的通用特化形式。
QDBusConnection 类
Qt6 中已移除了 QDBusConnection::sender() 函数。
QDBusMessage 类
QDBusMessage::createErrorReply() 函数现在通过 const 引用而非按值传递QString name 参数。
QDBusPendingReply 类
QDBusPendingReply 已更改为可变参数模板类,以便支持超过 8 个模板参数。这些模板参数是用于提取回复数据内容的类型。
© 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.