The Bluetooth API provides connectivity between Bluetooth enabled devices.
Currently, the API is supported on the following platforms:
|API Feature||Android||iOS||Linux (BlueZ 4.x/5.x)||macOS||UWP (Universal Windows Platform)||Win32|
|Bluetooth LE Central||x||x||x||x||x||x|
|Bluetooth LE Peripheral||x||x||x||x|
|Bluetooth LE Advertisement & Scanning|
Qt 5.14 adds a native Win32 port supporting Classic Bluetooth on Windows 7 or newer, and Bluetooth LE on Windows 8 or newer. It must be enabled at build time by configuration option -native-win32-bluetooth. The UWP backend is used by default if this option is not set and the Win32 target platform supports the required UWP APIs (minimal requirement is Windows 10 version 1507, with slightly improved service discovery since Windows 10 version 1607).
Bluetooth is a short-range (less than 100 meters) wireless technology. It has a reasonably high data transfer rate of 2.1 Mbit/s, which makes it ideal for transferring data between devices. Bluetooth connectivity is based on basic device management, such as scanning for devices, gathering information about them, and exchanging data between them.
Qt Bluetooth supports Bluetooth Low Energy development for client/central role use cases. Further details can be found in the Bluetooth Low Energy Overview section.
A new addition since the Qt Bluetooth 5.7 release covers support for Bluetooth Low Energy applications performing the peripheral/server role. This new API remains in Technology Preview.
To use the C++ library in your application, add the following configuration option to your
QT += bluetooth
To use the classes of the module in your application you need the following import statement in your
import QtBluetooth 5.12
Despite the fact that the module can be built for all Qt platforms, the module is not ported to all of them. Not supported platforms employ a fake or dummy backend which is automatically selected when the platform is not supported. The dummy backend reports appropriate error messages and values which allow the Qt Bluetooth developer to detect at runtime that the current platform is not supported. The dummy backend is also selected on Linux if BlueZ development headers are not found during build time or Qt was built without Qt D-Bus support.
The usage of the dummy backend is highlighted via an appropriate warning while building and running.
|qt.bluetooth||Enables logging of cross platform code path in QtBluetooth|
|qt.bluetooth.android||Enables logging of the Android implementation|
|qt.bluetooth.bluez||Enables logging of the BLuez/Linux implementation|
|qt.bluetooth.ios||Enables logging of the iOS implementation|
|qt.bluetooth.osx||Enables logging of the macOS implementation|
|qt.bluetooth.qml||Enables logging of the QtBluetooth QML implementation|
|qt.bluetooth.winrt||Enables logging of the UWP (Universal Windows Platform) implementation|
|qt.bluetooth.windows||Enables logging of the Win32 implementation|
Logging categories can be used to enable additional warning and debug output for QtBluetooth. More detailed information about logging can be found in QLoggingCategory. A quick way to enable all QtBluetooth logging is to add the following line to the
Qt Bluetooth is available under commercial licenses from The Qt Company. In addition, it is available under the GNU Lesser General Public License, version 3, or the GNU General Public License, version 2. See Qt Licensing for further details.
GNU General Public License v2.0 only (This does not force user code to be GPL'ed. For more info see details.)
© 2021 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.