蓝牙 API 提供蓝牙使能设备之间的连接。
|API 特征||Android||iOS||Linux (BlueZ 4.x/5.x)||macOS||UWP (通用 Windows 平台)||Win32|
|蓝牙 LE 中心||x||x||x||x||x||x|
|蓝牙 LE 外围||x||x||x||x|
|蓝牙 LE 广告和扫描|
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 低功耗蓝牙概述 章节。
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.
要使用 C++ 库在应用程序，添加以下配置选项到
QT += bluetooth
要在应用程序中使用模块的类，需要以下 import 语句在
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 实现|
|qt.bluetooth.bluez||Enables logging of the BLuez /Linux implementation|
|qt.bluetooth.ios||Enables logging of the iOS 实现|
|qt.bluetooth.osx||Enables logging of the macOS 实现|
|qt.bluetooth.qml||Enables logging of the QtBluetooth QML implementation|
|qt.bluetooth.winrt||Enables logging of the UWP (通用 Windows 平台) 实现|
|qt.bluetooth.windows||Enables logging of the Win32 实现|
Logging categories can be used to enable additional warning and debug output for
. More detailed information about logging can be found in
. A quick way to enable all
logging is to add the following line to the
GNU General Public License v2.0 only (This does not force user code to be GPL'ed. For more info see details.)