QBluetooth Namespace
QBluetooth 命名空间提供了与蓝牙相关的类和函数。更多内容...
| 头文件: | #include <qbluetooth.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Bluetooth) target_link_libraries(mytarget PRIVATE Qt6::Bluetooth) |
| qmake: | QT += bluetooth |
类型
| enum class | AttAccessConstraint { AttAuthorizationRequired, AttAuthenticationRequired, AttEncryptionRequired } |
| flags | AttAccessConstraints |
| QLowEnergyHandle | |
| enum class | Security { NoSecurity, Authorization, Authentication, Encryption, Secure } |
| flags | SecurityFlags |
类型文档
enum class QBluetooth::AttAccessConstraint
flags QBluetooth::AttAccessConstraints
此枚举描述了读取或写入 ATT 属性时可能需要满足的要求。
| 常量 | 值 | 描述 |
|---|---|---|
QBluetooth::AttAccessConstraint::AttAuthorizationRequired | 0x1 | 客户端需要获得 ATT 服务器的授权才能访问该属性。 |
QBluetooth::AttAccessConstraint::AttAuthenticationRequired | 0x2 | 客户端需要通过身份验证才能访问该属性。 |
QBluetooth::AttAccessConstraint::AttEncryptionRequired | 0x4 | 只有在连接经过加密的情况下,才能访问该属性。 |
AttAccessConstraints 类型是QFlags<AttAccessConstraint> 的 typedef 定义。它存储了 AttAccessConstraint 值的“或”组合。
QLowEnergyHandle
用于蓝牙低功耗(BLE)ATT属性句柄的typedef定义。
enum class QBluetooth::Security
flags QBluetooth::SecurityFlags
此枚举描述了蓝牙服务的安全要求。
| 常量 | 值 | 描述 |
|---|---|---|
QBluetooth::Security::NoSecurity | 0x00 | 该服务不需要任何安全措施。 |
QBluetooth::Security::Authorization | 0x01 | 除非设备处于“授权配对”状态,否则该服务需要用户授权。 |
QBluetooth::Security::Authentication | 0x02 | 该服务需要身份验证。设备必须已配对,并且除非设备属于“已授权配对”状态,否则在连接时会提示用户。 |
QBluetooth::Security::Encryption | 0x04 | 该服务要求通信链路必须加密。这要求设备已配对。 |
QBluetooth::Security::Secure | 0x08 | 该服务要求通信链路必须是安全的。必须使用蓝牙 2.1 或更高版本的“简单配对”功能。不允许使用传统配对方式。 |
SecurityFlags 类型是QFlags<Security> 的 typedef。它存储 Security 值的按“或”运算组合。
© 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.