QBluetoothLocalDevice Class
The QBluetoothLocalDevice class enables access to the local Bluetooth device. More...
| Header: | #include <QBluetoothLocalDevice> |
| qmake: | QT += bluetooth |
| Since: | Qt 5.2 |
| Inherits: | QObject |
This class was introduced in Qt 5.2.
Public Types
| enum | Error { NoError, PairingError, UnknownError } |
| enum | HostMode { HostPoweredOff, HostConnectable, HostDiscoverable, HostDiscoverableLimitedInquiry } |
| enum | Pairing { Unpaired, Paired, AuthorizedPaired } |
Detailed Description
QBluetoothLocalDevice provides functions for getting and setting the state of local Bluetooth devices.
On iOS and Windows, this class cannot be used because the platform does not expose any data or API which may provide information on the local Bluetooth device.
Member Type Documentation
enum QBluetoothLocalDevice::Error
This enum describes errors that maybe returned
| Constant | Value | Description |
|---|---|---|
QBluetoothLocalDevice::NoError | 0 | No known error |
QBluetoothLocalDevice::PairingError | 1 | Error in pairing |
QBluetoothLocalDevice::UnknownError | 100 | Unknown error |
enum QBluetoothLocalDevice::HostMode
This enum describes the most of the local Bluetooth device.
| Constant | Value | Description |
|---|---|---|
QBluetoothLocalDevice::HostPoweredOff | 0 | Power off the device |
QBluetoothLocalDevice::HostConnectable | 1 | Remote Bluetooth devices can connect to the local Bluetooth device if they have previously been paired with it or otherwise know its address. This powers up the device if it was powered off. |
QBluetoothLocalDevice::HostDiscoverable | 2 | Remote Bluetooth devices can discover the presence of the local Bluetooth device. The device will also be connectable, and powered on. On Android, this mode can only be active for a maximum of 5 minutes. |
QBluetoothLocalDevice::HostDiscoverableLimitedInquiry | 3 | Remote Bluetooth devices can discover the presence of the local Bluetooth device when performing a limited inquiry. This should be used for locating services that are only made discoverable for a limited period of time. This can speed up discovery between gaming devices, as service discovery can be skipped on devices not in LimitedInquiry mode. In this mode, the device will be connectable and powered on, if required. This mode is is not supported on Android. On macOS, it is not possible to set the hostMode() to HostConnectable or HostPoweredOff. |
Note: Starting from Android 13 (API level 33) the HostPoweredOff state relies on non-public Android API as the public one has been deprecated, see (disable()). This may change in a future version of Android.
Note: At least on Android 12 the device's Bluetooth visibility setting may dictate the result of setting either HostDiscoverable or HostConnectable. For example if the visibility is set off, it may not be possible to enter the HostDiscoverable mode, but HostConnectable will be used instead. This may change in future version of Android.
enum QBluetoothLocalDevice::Pairing
This enum describes the pairing state between the two Bluetooth devices.
| Constant | Value | Description |
|---|---|---|
QBluetoothLocalDevice::Unpaired | 0 | The Bluetooth devices are not paired. |
QBluetoothLocalDevice::Paired | 1 | The Bluetooth devices are paired. The system will prompt the user for authorization when the remote device initiates a connection to the local device. |
QBluetoothLocalDevice::AuthorizedPaired | 2 | The Bluetooth devices are paired. The system will not prompt the user for authorization when the remote device initiates a connection to the local device. |