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