Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
bluetooth-index.qdoc
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qtbluetooth-index.html
6\title Qt Bluetooth
7\brief Qt Bluetooth enables connectivity between Bluetooth enabled devices.
8\ingroup technology-apis
9
10The Bluetooth API provides connectivity between Bluetooth enabled devices.
11
12Currently, the API is supported on the following platforms:
13
14\table
15\header
16 \li API Feature
17 \li \l {Qt for Android}{Android}
18 \li \l {Qt for iOS}{iOS}
19 \li \l {Qt for Linux/X11}{Linux (BlueZ 5.x)}
20 \li \l \macos
21 \li \l {Qt for Windows}{Windows}
22\row
23 \li Classic Bluetooth
24 \li x
25 \li
26 \li x
27 \li x
28 \li x
29\row
30 \li Bluetooth LE Central
31 \li x
32 \li x
33 \li x
34 \li x
35 \li x
36\row
37 \li Bluetooth LE Peripheral
38 \li x
39 \li x
40 \li x
41 \li x
42 \li
43\endtable
44
45\section1 Overview
46
47Bluetooth is a short-range (less than 100 meters) wireless technology. It
48has a data transfer rate of 2.1 Mbps, which makes it ideal
49for transferring data between devices. Bluetooth connectivity is based on
50basic device management, such as scanning for devices, gathering information
51about them, and exchanging data between them.
52
53Qt Bluetooth supports Bluetooth Low Energy development for client/central role
54use cases. Further details can be found in the
55\l {Bluetooth Low Energy Overview}{Bluetooth Low Energy Overview} section.
56
57\section1 Using the Module
58
59\include {module-use.qdocinc} {using the c++ api}
60
61\section2 Building with CMake
62
63\include {module-use.qdocinc} {building with cmake} {Bluetooth}
64
65\section2 Building with qmake
66
67\include {module-use.qdocinc} {building_with_qmake} {bluetooth}
68
69\section1 Permissions
70
71Starting from Qt 6.6, the Qt Bluetooth module uses new \l QPermission API
72to handle \l {QBluetoothPermission}{Bluetooth} permissions. This means that Qt
73itself no longer queries for these permissions, so this needs to be done
74directly from the client application.
75
76Please refer to the \l {Application Permissions} page for an example of how
77to integrate the new \l QPermission API into the application.
78
79\section1 Related Information
80
81\section2 Building Qt Bluetooth
82
83Even though the module can be built for all Qt platforms, the module is not
84ported to all of them. Non-supported platforms employ a dummy backend that is
85automatically selected when the platform is not supported. The dummy backend
86reports appropriate error messages and values, which enables you to detect at
87runtime that the current platform is not supported. The dummy backend is also
88selected on Linux if BlueZ development headers are not found during build time
89or Qt was built without Qt D-Bus support.
90
91The usage of the dummy backend is highlighted via an appropriate warning while building and running.
92
93\section3 Linux Specific
94
95Since Qt 6.5 the Linux peripheral support has two backend alternatives:
96BlueZ DBus and Bluetooth kernel API. The Bluez DBus backend introduced in Qt 6.5 is
97intended as the eventual successor of the lower abstraction level kernel backend.
98
99The BlueZ DBus API is more limited in terms of features and is therefore not
100the default backend for compatibility reasons.
101
102The BlueZ DBus backend can be configured to use by setting
103the \e QT_BLUETOOTH_USE_DBUS_PERIPHERAL environment variable. The QLowEnergyController
104peripheral instantiation then introspects the presence of BlueZ DBus peripheral APIs
105on the local bluetooth adapter. The minimum version requirement for BlueZ is 5.56.
106
107One noteworthy difference is that with BlueZ DBus peripheral backend the user process no longer
108needs to have the \e CAP_NET_ADMIN capability (eg. run as root).
109
110\section3 \macos Specific
111The Bluetooth API on \macos requires a certain type of event dispatcher
112that in Qt causes a dependency to \l QGuiApplication. However, you can set the
113environment variable \c {QT_EVENT_DISPATCHER_CORE_FOUNDATION=1} to circumvent
114this issue.
115
116Applications that don't use Classic Bluetooth will find a subset of QtBluetooth
117is available, as CoreBluetooth (Bluetooth LE) don't require \l QApplication or
118\l QGuiApplication.
119
120\section2 Articles and Guides
121\list
122 \li \l {Qt Bluetooth Overview}{Classic Bluetooth Overview}
123 \li \l {Bluetooth Low Energy Overview}
124\endlist
125
126\section2 Reference
127\list
128 \li \l {Qt Bluetooth C++ Classes}{C++ Classes}
129\endlist
130
131\section2 Logging Categories
132
133The \l QtBluetooth module exports the following
134\l {Configuring Categories}{logging categories}:
135
136\table
137\header
138 \li Logging Category
139 \li Description
140\row
141 \li qt.bluetooth
142 \li Enables logging of cross platform code path in QtBluetooth
143\row
144 \li qt.bluetooth.android
145 \li Enables logging of the \l {Qt for Android} {Android} implementation
146\row
147 \li qt.bluetooth.bluez
148 \li Enables logging of the BLuez/Linux implementation
149\row
150 \li qt.bluetooth.ios
151 \li Enables logging of the \l {Qt for iOS} {iOS} implementation
152\row
153 \li qt.bluetooth.osx
154 \li Enables logging of the \l {Qt for macOS} {macOS} implementation
155\row
156 \li qt.bluetooth.windows
157 \li Enables logging of the \l {Qt for Windows} {Windows} implementation
158\endtable
159
160Logging categories enable additional warning and debug output for QtBluetooth.
161More detailed information about logging is found in \l QLoggingCategory. A
162quick way to enable all QtBluetooth logging is to add the following line to the
163\c main() function:
164
165\code
166 QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
167\endcode
168
169\section2 Examples
170\list
171 \li QML
172 \list
173 \li \l {heartrate-game}{Bluetooth Low Energy Heart Rate Game}
174 \li \l {heartrate-server}{Bluetooth Low Energy Heart Rate Server}
175 \li \l {lowenergyscanner}{Bluetooth Low Energy Scanner}
176 \endlist
177 \li C++
178 \list
179 \li \l {btchat}{Bluetooth Chat}
180 \endlist
181\endlist
182
183\section1 Module Evolution
184
185\l{Changes to Qt Bluetooth} lists important changes in the module
186API and functionality that were done for the Qt 6 series of Qt.
187
188\section1 Licenses and Attributions
189
190Qt Bluetooth is available under commercial licenses from \l{The Qt Company}.
191In addition, it is available under the
192\l{GNU Lesser General Public License, version 3}, or
193the \l{GNU General Public License, version 2}.
194See \l{Qt Licensing} for further details.
195
196On Linux, Qt Bluetooth uses a separate executable, \c sdpscanner,
197to integrate with the official Linux bluetooth protocol stack
198BlueZ. BlueZ is available under the \l{GNU General Public License,
199version 2}.
200
201\generatelist{groupsbymodule attributions-qtbluetooth}
202*/