このページでは

QBluetoothServiceInfo Class

QBluetoothServiceInfo クラスを使用すると、Bluetooth サービスの属性にアクセスできます。詳細...

ヘッダー: #include <QBluetoothServiceInfo>
CMake: find_package(Qt6 REQUIRED COMPONENTS Bluetooth)
target_link_libraries(mytarget PRIVATE Qt6::Bluetooth)
qmake: QT += bluetooth

パブリック型

class Alternative
class Sequence
enum AttributeId { ServiceRecordHandle, ServiceClassIds, ServiceRecordState, ServiceId, ProtocolDescriptorList, …, ServiceProvider }
enum Protocol { UnknownProtocol, L2capProtocol, RfcommProtocol }

パブリック関数

QBluetoothServiceInfo()
QBluetoothServiceInfo(const QBluetoothServiceInfo &other)
~QBluetoothServiceInfo()
QVariant attribute(quint16 attributeId) const
QList<quint16> attributes() const
bool contains(quint16 attributeId) const
QBluetoothDeviceInfo device() const
bool isComplete() const
bool isRegistered() const
bool isValid() const
QBluetoothServiceInfo::Sequence protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const
int protocolServiceMultiplexer() const
bool registerService(const QBluetoothAddress &localAdapter = QBluetoothAddress())
void removeAttribute(quint16 attributeId)
int serverChannel() const
quint8 serviceAvailability() const
QList<QBluetoothUuid> serviceClassUuids() const
QString serviceDescription() const
QString serviceName() const
QString serviceProvider() const
QBluetoothUuid serviceUuid() const
void setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Alternative &value)
void setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Sequence &value)
void setAttribute(quint16 attributeId, const QBluetoothUuid &value)
void setAttribute(quint16 attributeId, const QVariant &value)
void setDevice(const QBluetoothDeviceInfo &device)
void setServiceAvailability(quint8 availability)
void setServiceDescription(const QString &description)
void setServiceName(const QString &name)
void setServiceProvider(const QString &provider)
void setServiceUuid(const QBluetoothUuid &uuid)
QBluetoothServiceInfo::Protocol socketProtocol() const
bool unregisterService()
QBluetoothServiceInfo &operator=(const QBluetoothServiceInfo &other)

詳細な説明

QBluetoothServiceInfo は、Bluetooth デバイスが提供するサービスに関する情報を提供します。さらに、ローカルデバイス上で新しいサービスを登録するためにも使用できます。なお、このような登録は Bluetooth SDP エントリにのみ影響を与えることに注意してください。 着信接続を待機するサーバー(例:RFCOMMサーバー)は、registerService() が呼び出される前に起動されている必要があります。登録解除は、逆の順序で行う必要があります。

QBluetoothServiceInfoは、従来の意味での値型ではありません。同一のサービス情報オブジェクトのすべてのコピーは、変更を行っても切り離されないため、同じデータを共有します。これにより、2つのコピーが同一のBluetoothサービスを(登録/)解除できるようになります。

iOS では、プラットフォームが QBluetoothServiceInfo 関連の機能へのアクセスを許可する API を公開していないため、このクラスを使用することはできません。

メンバ型のドキュメント

enum QBluetoothServiceInfo::AttributeId

Bluetooth サービス属性。これらの属性に関するより詳細な説明については、『Bluetooth コア仕様書』をご参照ください。

定数値説明
QBluetoothServiceInfo::ServiceRecordHandle0x0000属性を取得できるサービスレコードを指定します。
QBluetoothServiceInfo::ServiceClassIds0x0001サービスが準拠するサービスクラスのUUID。最も一般的なサービスクラスは、(QBluetoothUuid::ServiceClassUuid) に定義されています。
QBluetoothServiceInfo::ServiceRecordState0x0002他のサービス属性が追加、削除、または変更されると、この属性も変更されます。
QBluetoothServiceInfo::ServiceId0x0003サービスを一意に識別する UUID。
QBluetoothServiceInfo::ProtocolDescriptorList0x0004サービスが使用するプロトコルのリスト。最も一般的なプロトコルの UUID は、QBluetoothUuid::ProtocolUuid
QBluetoothServiceInfo::BrowseGroupList0x0005サービスが属するブラウズグループのリスト。
QBluetoothServiceInfo::LanguageBaseAttributeIdList0x0006人間が読み取れる属性をサポートするための、言語ベース属性 ID のリスト。
QBluetoothServiceInfo::ServiceInfoTimeToLive0x0007サービスレコードが有効で変更されないまま維持されると予想される秒数。
QBluetoothServiceInfo::ServiceAvailability0x0008サービスの可用性を示す値。
QBluetoothServiceInfo::BluetoothProfileDescriptorList0x0009サービスが準拠するプロファイルの一覧。
QBluetoothServiceInfo::DocumentationUrl0x000Aサービスに関するドキュメントへのURL。
QBluetoothServiceInfo::ClientExecutableUrl0x000Bサービスを利用するために使用できるアプリケーションの場所を示すURL。
QBluetoothServiceInfo::IconUrl0x000Cサービスを表すアイコンの場所へのURL。
QBluetoothServiceInfo::AdditionalProtocolDescriptorList0x000Dサービスで使用される追加のプロトコル。この属性は、ProtocolDescriptorList を拡張するものである。
QBluetoothServiceInfo::PrimaryLanguageBase0x0100主要言語のテキスト記述子の基本インデックス。
QBluetoothServiceInfo::ServiceNamePrimaryLanguageBase + 0x0000主要言語でのBluetoothサービスの名称。
QBluetoothServiceInfo::ServiceDescriptionPrimaryLanguageBase + 0x0001主要言語による Bluetooth サービスの説明。
QBluetoothServiceInfo::ServiceProviderPrimaryLanguageBase + 0x0002Bluetooth サービスの主要言語を提供する企業/団体の名前。

注: Windowsでは 、サービスが作成される際、ServiceClassIds および ProtocolDescriptorList は自動的にデフォルト値に設定されます。これらの属性の値を手動で設定しても機能せず、このプラットフォーム上で予期しない結果につながる可能性があります。

enum QBluetoothServiceInfo::Protocol

この列挙型は、サービスで使用されるソケットプロトコルを記述するものです。

定数値説明
QBluetoothServiceInfo::UnknownProtocol0サービスは不明なソケットプロトコルを使用しています。
QBluetoothServiceInfo::L2capProtocol1サービスは L2CAP ソケットプロトコルを使用しています。このプロトコルは、Android での直接ソケット接続ではサポートされていません。
QBluetoothServiceInfo::RfcommProtocol2このサービスは RFCOMM ソケットプロトコルを使用しています。

メンバ関数のドキュメント

QBluetoothServiceInfo::QBluetoothServiceInfo()

新しい無効なQBluetoothServiceInfoを構築する;

QBluetoothServiceInfo::QBluetoothServiceInfo(const QBluetoothServiceInfo &other)

other のコピーとなる新しいQBluetoothServiceInfoを作成します。

これら 2 つのコピーは、書き込みを行っても切り離されない同じ基底データを引き続き共有します。

[noexcept] QBluetoothServiceInfo::~QBluetoothServiceInfo()

QBluetoothServiceInfo オブジェクトを破棄します。

QVariant QBluetoothServiceInfo::attribute(quint16 attributeId) const

属性「attributeId 」の値を返します。

setAttribute()も参照してください 。

QList<quint16> QBluetoothServiceInfo::attributes() const

QBluetoothServiceInfo オブジェクトが持つすべての属性IDのリストを返します。

bool QBluetoothServiceInfo::contains(quint16 attributeId) const

QBluetoothServiceInfo オブジェクトにattributeId という属性が含まれている場合はtrueを返し、そうでない場合はfalseを返します。

QBluetoothDeviceInfo QBluetoothServiceInfo::device() const

このサービスを提供するBluetoothデバイスのアドレスを返します。

setDevice()も参照してください 。

bool QBluetoothServiceInfo::isComplete() const

QBluetoothServiceInfo オブジェクトが完全であるとみなされる場合はtrueを返し、そうでない場合はfalseを返します。

完全なQBluetoothServiceInfo オブジェクトには、ProtocolDescriptorList 属性が含まれています。

bool QBluetoothServiceInfo::isRegistered() const

サービス情報がプラットフォームのサービスディスカバリープロトコル(SDP)の実装に登録されている場合は true を返し、そうでない場合は false を返します。

bool QBluetoothServiceInfo::isValid() const

QBluetoothServiceInfo オブジェクトが有効な場合はtrueを返し、そうでない場合はfalseを返します。

無効なQBluetoothServiceInfo オブジェクトには属性がありません。

QBluetoothServiceInfo::Sequence QBluetoothServiceInfo::protocolDescriptor(QBluetoothUuid::ProtocolUuid protocol) const

プロトコル `protocol` のプロトコルパラメータを `QBluetoothServiceInfo::Sequence ` として返します。

protocol がサポートされていない場合は、空の `QBluetoothServiceInfo::Sequence ` が返されます。

int QBluetoothServiceInfo::protocolServiceMultiplexer() const

これは利便性を高めるための関数です。L2CAPプロトコルをサポートするサービスのプロトコル/サービスマルチプレクサを返します。サポートしていない場合は-1を返します。

この関数は、QBluetoothServiceInfo::attribute(QBluetoothServiceInfo::ProtocolDescriptorList) によって返されるQBluetoothServiceInfo::Sequence から情報を抽出することと同等です。

bool QBluetoothServiceInfo::registerService(const QBluetoothAddress &localAdapter = QBluetoothAddress())

このサービスをプラットフォームのサービスディスカバリープロトコル(SDP)の実装に登録し、他のデバイスがサービスディスカバリーを実行した際に、そのサービスが検出可能になるようにします。サービスの登録に成功した場合は true を返し、失敗した場合は false を返します。一度登録されたレコードの変更はできません。変更を行うには、サービスを登録解除してから、変更を加えて再度登録する必要があります。

localAdapter パラメータは、サービスを登録する対象となるローカルBluetoothアダプタを指定します。localAdapter がnull の場合、デフォルトのBluetoothアダプタが使用されます。このサービス情報オブジェクトがすでにローカルアダプタ経由で登録されており、別のローカルアダプタを使用してこの関数が呼び出された場合、以前の登録は削除され、新しいアダプタを使用してサービスが再登録されます。

void QBluetoothServiceInfo::removeAttribute(quint16 attributeId)

QBluetoothServiceInfo オブジェクトから属性attributeId を削除します。

サービス情報がプラットフォームの SDP データベースにすでに登録されている場合、registerService() が再度呼び出されるまで、データベースのエントリは更新されません。

int QBluetoothServiceInfo::serverChannel() const

これは利便性を高めるための関数です。RFCOMMプロトコルをサポートするサービスについてはサーバーチャネルを返し、そうでない場合は-1を返します。

この関数は、QBluetoothServiceInfo::attribute (QBluetootherServiceInfo::ProtocolDescriptorList)によって返されるQBluetoothServiceInfo::Sequence から情報を抽出することと同等です。

quint8 QBluetoothServiceInfo::serviceAvailability() const

これは利便性を高めるための関数です。これは、attribute(QBluetoothServiceInfo::ServiceAvailability).toUInt() を呼び出すのと同じです。

サービスの利用可能状態を返します。

setServiceAvailability() およびattribute()も参照してください 。

QList<QBluetoothUuid> QBluetoothServiceInfo::serviceClassUuids() const

このサービスが準拠するサービスクラスを表す UUID のリストを返します。

これは利便性を高めるための関数です。これは、attribute(QBluetoothServiceInfo::ServiceClassIds).value<QBluetoothServiceInfo::Sequence>() を呼び出し、その後そのQBluetoothUuid エントリを反復処理することと同等です。

attribute()も参照してください 。

QString QBluetoothServiceInfo::serviceDescription() const

これは利便性を高めるための関数です。これは、attribute(QBluetoothServiceInfo::ServiceDescription).toString() を呼び出すのと同じです。

主要言語でのサービス説明を返します。

setServiceDescription() およびattribute()も参照してください 。

QString QBluetoothServiceInfo::serviceName() const

これは便利な関数です。これは、attribute(QBluetoothServiceInfo::ServiceName).toString() を呼び出すのと同じです。

プライマリ言語でのサービス名を返します。

setServiceName() およびattribute()も参照してください 。

QString QBluetoothServiceInfo::serviceProvider() const

これは利便性向上のための関数です。これは、attribute(QBluetoothServiceInfo::ServiceProvider).toString() を呼び出すのと同じ効果があります。

プライマリ言語のサービスプロバイダを返します。

setServiceProvider() およびattribute()も参照してください 。

QBluetoothUuid QBluetoothServiceInfo::serviceUuid() const

これは利便性を高めるための関数です。これは、attribute(QBluetoothServiceInfo::ServiceId).value<QBluetoothUuid>() を呼び出すのと同じです。

サービスのカスタム UUID を返します。この UUID は null になる場合があります。Bluetooth SIG 規格に基づく UUID は、serviceClassUuids() を通じて取得する必要があります。

setServiceUuid() およびattribute()も参照してください 。

void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Alternative &value)

これは便利関数です。

attributeId で指定された属性をvalue に設定します。

サービス情報がプラットフォームの SDP データベースにすでに登録されている場合、registerService() が再度呼び出されるまで、データベースのエントリは更新されません。

attribute()も参照してください 。

void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QBluetoothServiceInfo::Sequence &value)

これは便利な関数です。

attributeId で指定された属性を、value に設定します。

サービス情報がプラットフォームの SDP データベースにすでに登録されている場合、registerService() が再度呼び出されるまで、データベースのエントリは更新されません。

void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QBluetoothUuid &value)

これは便利な関数です。

attributeId で指定された属性を、value に設定します。

サービス情報がプラットフォームの SDP データベースにすでに登録されている場合、registerService() が再度呼び出されるまで、データベースのエントリは更新されません。

void QBluetoothServiceInfo::setAttribute(quint16 attributeId, const QVariant &value)

attributeId で指定された属性をvalue に設定します。

サービス情報がプラットフォームの SDP データベースにすでに登録されている場合、registerService() が再度呼び出されるまで、データベースのエントリは更新されません。

注: 属性がバイトエンコードされた値を必要とする場合 (例:Bluetooth HID サービス)、その属性はQByteArray として設定する必要があります。

isRegistered() およびregisterService()も参照してください 。

void QBluetoothServiceInfo::setDevice(const QBluetoothDeviceInfo &device)

このサービスを提供するBluetoothデバイスをdevice に設定します。

device()も参照してください 。

void QBluetoothServiceInfo::setServiceAvailability(quint8 availability)

これは便利な関数です。setAttribute(QBluetoothServiceInfo::ServiceAvailability, availability) を呼び出すのと同じです。

サービスの可用性を `availability` に設定します。

serviceAvailability() およびsetAttribute()も参照してください 。

void QBluetoothServiceInfo::setServiceDescription(const QString &description)

これは利便性を高めるための関数です。setAttribute(QBluetoothServiceInfo::ServiceDescription, description) を呼び出すのと同じです。

プライマリ言語でのサービス説明を `description` に設定します。

serviceDescription() およびsetAttribute()も参照してください 。

void QBluetoothServiceInfo::setServiceName(const QString &name)

これは利便性を高めるための関数です。setAttribute(QBluetoothServiceInfo::ServiceName, name) を呼び出すのと同じです。

プライマリ言語のサービス名を `name` に設定します。

serviceName() およびsetAttribute()も参照してください 。

void QBluetoothServiceInfo::setServiceProvider(const QString &provider)

これは利便性を高めるための関数です。setAttribute(QBluetoothServiceInfo::ServiceProvider, provider) を呼び出すのと同じです。

プライマリ言語のサービスプロバイダを `provider` に設定します。

serviceProvider() およびsetAttribute()も参照してください 。

void QBluetoothServiceInfo::setServiceUuid(const QBluetoothUuid &uuid)

これは利便性を高めるための関数です。setAttribute(QBluetoothServiceInfo::ServiceId, uuid) を呼び出すのと同じ効果があります。

カスタムサービスの UUID を `uuid` に設定します。この関数は、標準化されたサービス UUID を設定するために使用しないでください。

serviceUuid() およびsetAttribute()も参照してください 。

QBluetoothServiceInfo::Protocol QBluetoothServiceInfo::socketProtocol() const

QBluetoothServiceInfo オブジェクトが使用するプロトコルを返します。

bool QBluetoothServiceInfo::unregisterService()

プラットフォームのサービスディスカバリープロトコル(SDP)の実装から、このサービスの登録を解除します。これ以降、他のデバイスはサービスディスカバリーを通じてこのサービスを見つけられなくなります。

サービスの登録解除に成功した場合はtrueを返し、失敗した場合はfalseを返します。

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

other のコピーを作成し、それをこのQBluetoothServiceInfo オブジェクトに割り当てます。2つのコピーは、引き続き同じサービスおよび登録情報を共有します。

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