Changes to Qt Bluetooth

Qt 6 是努力使框架更高效,且更易于使用的结果。

为兼容每个发行的所有公共 API,我们试着维护二进制和源代码。但是,为使 Qt 成为更优框架,一些改变是不可避免的。

In this topic we summarize those changes in QtBluetooth , and provide guidance to handle them.

一般

  • qbluetoothglobal.h was removed. qtbluetoothglobal.h is the official header with the same purpose.
  • Every usage of QVector has been replaced by QList .
  • Win32 backend has been removed. There will not be a working Bluetooth backend when Qt is built with mingw.
  • Since there is now only one Windows backend, the logging category qt.bluetooth.winrt was removed. The corresponding log messages are now in qt.bluetooth.windows.

QBluetooth namespace

The enums QBluetooth::Security and QBluetooth::AttAccessConstraint have been changed to a scoped enums for improved type safety.

QBluetoothDeviceDiscoveryAgent

QBluetoothDeviceDiscoveryAgent::inquiryType property and related setter/getter & enum were removed. The API element was never implemented and/or supported.

QBluetoothDeviceInfo

QBluetoothLocalDevice

The pairing agent related API was removed without replacement. This includes pairingConfirmation(bool), pairingDisplayPinCode(..) & pairingDisplayConfirmation(..). Except for Android and BlueZ 4 there was never an implementation for it. Bluez 4 support was removed in Qt 6 and Android's implementation required unobtainable BLUETOOTH_PRIVILEGED for at least parts of the code.

QLowEnergyService

Renamed ServiceState enum values:

This change happens in anticipation that service discovery might become an optional step in the future.

QBluetoothUuid

enums ProtocolUuid , ServiceClassUuid , CharacteristicType ,和 DescriptorType are now scoped enums. The usage of enum items has to be adapted in user code.

QLowEnergyController

QLowEnergyCharacteristic

  • The new method clientCharacteristicConfiguration() has been introduced to conveniently obtain the Client Characteristic Configuration Descriptor.
  • The constants CCCDDisable , CCCDEnableNotification ,和 CCCDEnableIndication have been introduced which hold the possible values for the Client Characteristic Configuration Descriptor.
  • The handle() method is no longer part of the public Bluetooth LE interfaces. It's purpose as identifier for characteristics was replaced. The QLowEnergyCharacteristic instances itself serve as identifier.

QLowEnergyDescriptor

The handle() method is no longer part of the public Bluetooth LE interfaces. It's purpose as identifier for descriptors was replaced. The QLowEnergyDescriptor instances itself serve as identifier.

QBluetoothTransferManager

QBluetoothTransferManager, QBluetoothTransferRequest, and QBluetoothTransferReply have been removed without replacement.

QBluetoothSocket

QBluetoothSocket::SocketState and QBluetoothSocket::SocketError are now scoped enums. The usage of enum items has to be adapted in user code.

QML Interface

The QML interface has been removed because socket programming via QML is not advisable. QDeclarativeBluetoothService, QDeclarativeBluetoothSocket, and QDeclarativeBluetoothDiscoveryModel (in QML: BluetoothService, BluetoothSocket, and BluetoothDiscoveryModel) have been removed without replacement.

"error" signals

The "error" signals in QBluetoothDeviceDiscoveryAgent , QBluetoothLocalDevice , QBluetoothServer , QBluetoothServiceDiscoveryAgent , QBluetoothSocket , QLowEnergyController ,和 QLowEnergyService have been renamed to "errorOccurred" to remove ambiguities between the "error" signal and the "error" getter.