QLowEnergyDescriptor Class

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

Header: #include <QLowEnergyDescriptor>
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() 也会相应更新。

另请参阅 QLowEnergyServiceQLowEnergyCharacteristic

成员函数文档

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 Descriptors 下找到。

如果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 实例指向同一个远程蓝牙低功耗设备上的同一个描述符,或者两个实例都是默认构建的,则视为相等。

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