本页内容

QLowEnergyDescriptorData Class

QLowEnergyDescriptorData 类用于创建 GATT 服务数据。更多内容...

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

公共函数

QLowEnergyDescriptorData()
QLowEnergyDescriptorData(const QBluetoothUuid &uuid, const QByteArray &value)
QLowEnergyDescriptorData(const QLowEnergyDescriptorData &other)
~QLowEnergyDescriptorData()
bool isReadable() const
bool isValid() const
bool isWritable() const
QBluetooth::AttAccessConstraints readConstraints() const
void setReadPermissions(bool readable, QBluetooth::AttAccessConstraints constraints = QBluetooth::AttAccessConstraints())
void setUuid(const QBluetoothUuid &uuid)
void setValue(const QByteArray &value)
void setWritePermissions(bool writable, QBluetooth::AttAccessConstraints constraints = QBluetooth::AttAccessConstraints())
void swap(QLowEnergyDescriptorData &other)
QBluetoothUuid uuid() const
QByteArray value() const
QBluetooth::AttAccessConstraints writeConstraints() const
QLowEnergyDescriptorData &operator=(const QLowEnergyDescriptorData &other)
bool operator!=(const QLowEnergyDescriptorData &a, const QLowEnergyDescriptorData &b)
bool operator==(const QLowEnergyDescriptorData &a, const QLowEnergyDescriptorData &b)

详细说明

该类的对象提供了一个描述符,可通过 `QLowEnergyCharacteristicData::addDescriptor()` 将其添加到 `QLowEnergyCharacteristicData ` 对象中。

注意: 与访问权限相关的成员函数 仅适用于那些蓝牙规范未规定是否以及如何访问其值的描述符类型。

另请参阅 QLowEnergyCharacteristicData 、QLowEnergyServiceData 和QLowEnergyController::addService 。

成员函数文档

QLowEnergyDescriptorData::QLowEnergyDescriptorData()

创建该类的一个新的无效对象。

QLowEnergyDescriptorData::QLowEnergyDescriptorData(const QBluetoothUuid &uuid, const QByteArray &value)

创建该类的一个新对象,其 UUID 和值分别由uuid 和value 提供。

QLowEnergyDescriptorData::QLowEnergyDescriptorData(const QLowEnergyDescriptorData &other)

创建该类的一个新对象,该对象是other 的副本。

[noexcept] QLowEnergyDescriptorData::~QLowEnergyDescriptorData()

销毁此对象。

bool QLowEnergyDescriptorData::isReadable() const

如果该描述符的值可读,则返回true ;否则返回false 。

bool QLowEnergyDescriptorData::isValid() const

当且仅当该对象具有一个非空的 UUID 时,返回 true。

bool QLowEnergyDescriptorData::isWritable() const

如果该描述符的值可写,则返回true ;否则返回false 。

QBluetooth::AttAccessConstraints QLowEnergyDescriptorData::readConstraints() const

返回读取该描述符值时所受的约束条件。只有当isReadable()返回true 时,此值才具有意义。

void QLowEnergyDescriptorData::setReadPermissions(bool readable, QBluetooth::AttAccessConstraints constraints = QBluetooth::AttAccessConstraints())

指定该描述符的值是否为readable ;如果是,则指定其所属的constraints 。

另请参阅 setWritePermissions()。

void QLowEnergyDescriptorData::setUuid(const QBluetoothUuid &uuid)

将此描述符的 UUID 设置为uuid 。

另请参阅 uuid()。

void QLowEnergyDescriptorData::setValue(const QByteArray &value)

将此描述符的值设置为value 。该值将完全按照此处提供的形式发送给对等设备,因此调用方需要注意字节序等问题。

另请参阅 value()。

void QLowEnergyDescriptorData::setWritePermissions(bool writable, QBluetooth::AttAccessConstraints constraints = QBluetooth::AttAccessConstraints())

指定该描述符的值是否为writable ;如果是,则指定其所属的constraints 。

另请参阅 setReadPermissions()。

[noexcept] void QLowEnergyDescriptorData::swap(QLowEnergyDescriptorData &other)

将此对象与other 互换。

QBluetoothUuid QLowEnergyDescriptorData::uuid() const

返回此描述符的 UUID。

另请参阅 setUuid()。

QByteArray QLowEnergyDescriptorData::value() const

返回该描述符的值。

另请参阅 setValue()。

QBluetooth::AttAccessConstraints QLowEnergyDescriptorData::writeConstraints() const

返回该描述符的值可被写入时所遵循的约束条件。只有当isWritable()返回true 时,此值才具有相关性。

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

将该对象复制为other 的副本,并返回该对象的新值。

相关的非成员

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

如果a 和b 的公共状态不相同,则返回true ;否则返回false 。

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

如果a 和b 的公共状态相等,则返回true ;否则返回false 。

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