本页内容

QLowEnergyDescriptor Class

QLowEnergyDescriptor 类用于存储有关蓝牙低功耗描述符的信息。更多内容...

头文件: #include <QLowEnergyDescriptor>
CMake: find_package(Qt6 REQUIRED COMPONENTS Bluetooth)
target_link_libraries(mytarget PRIVATE Qt6::Bluetooth)
qmake: QT += bluetooth

公共函数

QLowEnergyDescriptor()
QLowEnergyDescriptor(const QLowEnergyDescriptor &other)
~QLowEnergyDescriptor()
bool isValid() const
QString name() const
QBluetoothUuid::DescriptorType type() const
QBluetoothUuid uuid() const
QByteArray value() const
QLowEnergyDescriptor &operator=(const QLowEnergyDescriptor &other)
bool operator!=(const QLowEnergyDescriptor &a, const QLowEnergyDescriptor &b)
bool operator==(const QLowEnergyDescriptor &a, const QLowEnergyDescriptor &b)

详细说明

QLowEnergyDescriptor 提供有关蓝牙低功耗描述符的 `name()`、`uuid()` 和 `value()` 的信息。描述符由蓝牙低功耗特征封装,并为特征提供额外的上下文信息(数据格式、通知激活等)。

描述符的值可通过管理该描述符所属服务的QLowEnergyService 实例进行写入。QLowEnergyService::writeDescriptor() 函数用于写入新值。成功时会发出QLowEnergyService::descriptorWritten() 信号。该对象的缓存value() 将相应更新。

另请参阅 QLowEnergyService 和QLowEnergyCharacteristic 。

成员函数文档

QLowEnergyDescriptor::QLowEnergyDescriptor()

构建一个新的 QLowEnergyDescriptor。该类的默认构造实例始终无效。

QLowEnergyDescriptor::QLowEnergyDescriptor(const QLowEnergyDescriptor &other)

构建一个新的 QLowEnergyDescriptor,该对象是other 的副本。

这两个副本将继续共享相同的底层数据,该数据在写入时不会被分离。

[noexcept] QLowEnergyDescriptor::~QLowEnergyDescriptor()

销毁QLowEnergyDescriptor 对象。

bool QLowEnergyDescriptor::isValid() const

如果QLowEnergyDescriptor 对象有效,则返回true ;否则返回false 。

无效的描述符实例要么未与任何服务相关联(默认构造),要么由于与底层蓝牙低功耗设备断开连接等原因,其关联的服务已不再有效。一旦对象失效,便无法再次生效。

注意:如果 QLowEnergyDescriptor 实例因与底层设备断开连接而失效,当前实例封装的信息将保持断开连接时的状态。因此,在断开连接事件发生后仍可检索该信息。

QString QLowEnergyDescriptor::name() const

返回描述符的人类可读名称。

该名称基于描述符的type()。描述符类型的完整列表可在Bluetooth.org的“描述符”部分中找到。

如果type() 未知,则返回的字符串为空。

另请参阅 type() 和QBluetoothUuid::descriptorToString()。

QBluetoothUuid::DescriptorType QLowEnergyDescriptor::type() const

返回描述符的类型。

另请参阅 name()。

QBluetoothUuid QLowEnergyDescriptor::uuid() const

如果isValid()返回true ,则返回该描述符的UUID;否则返回null 的UUID。

QByteArray QLowEnergyDescriptor::value() const

返回描述符的缓存值。

可通过调用QLowEnergyService::writeDescriptor()或QLowEnergyService::readDescriptor()来更新缓存的描述符值。

QLowEnergyDescriptor &QLowEnergyDescriptor::operator=(const QLowEnergyDescriptor &other)

创建other 的副本,并将其赋值给此QLowEnergyDescriptor 对象。这两个副本继续共享相同的服务和控制器详细信息。

相关的非成员

bool operator!=(const QLowEnergyDescriptor &a, const QLowEnergyDescriptor &b)

如果a 不等于b ,则返回true ;否则返回false 。

如果两个 `QLowEnergyDescriptor ` 实例指向同一台远程蓝牙低功耗设备上的同一描述符,或者这两个实例均通过默认构造函数初始化,则认为它们相等。

bool operator==(const QLowEnergyDescriptor &a, const QLowEnergyDescriptor &b)

如果a 等于b ,则返回true ;否则返回false 。

如果两个 `QLowEnergyDescriptor ` 实例引用的是同一台远程蓝牙低功耗设备上的同一描述符,或者这两个实例均通过默认构造函数创建,则视为相等。

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