Nesta página

QLowEnergyServiceData Class

A classe QLowEnergyServiceData é usada para configurar os dados de serviço GATT. Saiba mais...

Cabeçalho: #include <QLowEnergyServiceData>
CMake: find_package(Qt6 REQUIRED COMPONENTS Bluetooth)
target_link_libraries(mytarget PRIVATE Qt6::Bluetooth)
qmake: QT += bluetooth

Tipos públicos

enum ServiceType { ServiceTypePrimary, ServiceTypeSecondary }

Funções públicas

QLowEnergyServiceData()
QLowEnergyServiceData(const QLowEnergyServiceData &other)
~QLowEnergyServiceData()
void addCharacteristic(const QLowEnergyCharacteristicData &characteristic)
void addIncludedService(QLowEnergyService *service)
QList<QLowEnergyCharacteristicData> characteristics() const
QList<QLowEnergyService *> includedServices() const
bool isValid() const
void setCharacteristics(const QList<QLowEnergyCharacteristicData> &characteristics)
void setIncludedServices(const QList<QLowEnergyService *> &services)
void setType(QLowEnergyServiceData::ServiceType type)
void setUuid(const QBluetoothUuid &uuid)
void swap(QLowEnergyServiceData &other)
QLowEnergyServiceData::ServiceType type() const
QBluetoothUuid uuid() const
QLowEnergyServiceData &operator=(const QLowEnergyServiceData &other)
bool operator!=(const QLowEnergyServiceData &a, const QLowEnergyServiceData &b)
bool operator==(const QLowEnergyServiceData &a, const QLowEnergyServiceData &b)

Descrição detalhada

Um objeto dessa classe fornece um serviço a ser adicionado a um servidor GATT por meio de ` QLowEnergyController::addService()`.

Documentação dos tipos de membros

enum QLowEnergyServiceData::ServiceType

O tipo de serviço do GATT.

ConstanteValorDescrição
QLowEnergyServiceData::ServiceTypePrimary0x2800O serviço é um serviço primário.
QLowEnergyServiceData::ServiceTypeSecondary0x2801O serviço é um serviço secundário. Os serviços secundários são incluídos por outros serviços para implementar alguma funcionalidade de nível superior.

Documentação da função membro

QLowEnergyServiceData::QLowEnergyServiceData()

Cria um novo objeto inválido desta classe.

QLowEnergyServiceData::QLowEnergyServiceData(const QLowEnergyServiceData &other)

Cria um novo objeto desta classe que é uma cópia de ` other`.

[noexcept] QLowEnergyServiceData::~QLowEnergyServiceData()

Destrói este objeto.

void QLowEnergyServiceData::addCharacteristic(const QLowEnergyCharacteristicData &characteristic)

Adiciona “ characteristic ” à lista de características, caso seja válido.

Veja também setCharacteristics().

void QLowEnergyServiceData::addIncludedService(QLowEnergyService *service)

Adiciona service à lista de serviços incluídos. O objeto service deve ter sido retornado por uma chamada à função QLowEnergyController::addService. Esse requisito evita inclusões circulares (que são proibidas pela especificação Bluetooth) e também ajuda a dar suporte ao caso de uso em que se inclui mais de um serviço do mesmo tipo.

Veja também setIncludedServices().

QList<QLowEnergyCharacteristicData> QLowEnergyServiceData::characteristics() const

Retorna a lista de características.

Veja também setCharacteristics().

QList<QLowEnergyService *> QLowEnergyServiceData::includedServices() const

Retorna a lista de serviços incluídos.

Veja também setIncludedServices().

bool QLowEnergyServiceData::isValid() const

Retorna ` true ` se este serviço tiver um UUID diferente de nulo.

void QLowEnergyServiceData::setCharacteristics(const QList<QLowEnergyCharacteristicData> &characteristics)

Define a lista de características como characteristics. Apenas as características válidas são consideradas.

Veja também characteristics() e addCharacteristic().

void QLowEnergyServiceData::setIncludedServices(const QList<QLowEnergyService *> &services)

Define a lista de serviços incluídos como services. Todos os objetos nessa lista devem ter sido retornados por uma chamada à função QLowEnergyController::addService.

Veja também includedServices() e addIncludedService().

void QLowEnergyServiceData::setType(QLowEnergyServiceData::ServiceType type)

Define o tipo deste serviço como “ type ”.

Veja também type().

void QLowEnergyServiceData::setUuid(const QBluetoothUuid &uuid)

Define o UUID deste serviço como uuid.

Veja também uuid().

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

Troca este objeto por other.

QLowEnergyServiceData::ServiceType QLowEnergyServiceData::type() const

Retorna o tipo deste serviço.

Veja também ` setType()`.

QBluetoothUuid QLowEnergyServiceData::uuid() const

Retorna o UUID deste serviço.

Veja também setUuid().

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

Transforma este objeto em uma cópia de ` other ` e retorna o novo valor deste objeto.

Não-membros relacionados

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

Retorna ` true ` se ` a ` e ` b ` forem diferentes no que diz respeito ao seu estado público; caso contrário, retorna ` false`.

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

Retorna ` true ` se ` a ` e ` b ` forem iguais em relação ao seu estado público; caso contrário, retorna ` 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.