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 }

Public Functions

virtual ~QBluetoothLocalDevice()
bool isValid() const
  • 16 public functions inherited from QObject
typedef QObjectList

Macros

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 5 static public members inherited from QObject
  • 8 protected functions inherited from QObject

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

ConstantValueDescription
QBluetoothLocalDevice::NoError0No known error
QBluetoothLocalDevice::PairingError1Error in pairing
QBluetoothLocalDevice::UnknownError100Unknown error

enum QBluetoothLocalDevice::HostMode

This enum describes the most of the local Bluetooth device.

ConstantValueDescription
QBluetoothLocalDevice::HostPoweredOff0Power off the device
QBluetoothLocalDevice::HostConnectable1Remote 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::HostDiscoverable2Remote 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::HostDiscoverableLimitedInquiry3Remote 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.

enum QBluetoothLocalDevice::Pairing

This enum describes the pairing state between the two Bluetooth devices.

ConstantValueDescription
QBluetoothLocalDevice::Unpaired0The Bluetooth devices are not paired.
QBluetoothLocalDevice::Paired1The Bluetooth devices are paired. The system will prompt the user for authorization when the remote device initiates a connection to the local device.
QBluetoothLocalDevice::AuthorizedPaired2The Bluetooth devices are paired. The system will not prompt the user for authorization when the remote device initiates a connection to the local device.

Member Function Documentation

[virtual] QBluetoothLocalDevice::~QBluetoothLocalDevice()

Destroys the QBluetoothLocalDevice.

bool QBluetoothLocalDevice::isValid() const

Returns true if the QBluetoothLocalDevice represents an available local Bluetooth device; otherwise return false.

If the local Bluetooth adapter represented by an instance of this class is removed from the system (e.g. removal of the underlying Bluetooth dongle) then this instance will become invalid. An already invalid QBluetoothLocalDevice instance remains invalid even if the same Bluetooth adapter is returned to the system.

See also allDevices().