IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Qt Bluetooth

Qt Bluetooth enables connectivity between Bluetooth enabled devices.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Qt Bluetooth▲

The Bluetooth API provides connectivity between Bluetooth enabled devices.

Currently, the API is supported on the following platforms:

API Feature

Android

iOS

Linux (BlueZ 5.x)

macOS

Windows

Classic Bluetooth

x

 

x

x

x

Bluetooth LE Central

x

x

x

x

x

Bluetooth LE Peripheral

x

x

x

x

 

Bluetooth LE Advertisement & Scanning

         

Overview▲

Bluetooth is a short-range (less than 100 meters) wireless technology. It has a data transfer rate of 2.1 Mbps, 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 https:// section.

Using the Module▲

Using a Qt module requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including http:// and https://.

Building with CMake▲

Use the find_package() command to locate the needed module component in the Qt6 package:

 
Sélectionnez
find_package(Qt6 REQUIRED COMPONENTS Bluetooth)
target_link_libraries(mytarget PRIVATE Qt6::Bluetooth)

For more details, see the Build with CMake overview.

Building with qmake▲

To configure the module for building with qmake, add the module as a value of the QT variable in the project's .pro file:

 
Sélectionnez
QT += bluetooth

Related Information▲

 

Building Qt Bluetooth▲

Even though the module can be built for all Qt platforms, the module is not ported to all of them. Non-supported platforms employ a dummy backend that is automatically selected when the platform is not supported. The dummy backend reports appropriate error messages and values, which enables you 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.

macOS Specific▲

The Bluetooth API on macOS requires a certain type of event dispatcher that in Qt causes a dependency to https://. However, you can set the environment variable QT_EVENT_DISPATCHER_CORE_FOUNDATION=1 to circumvent this issue.

Applications that don't use Classic Bluetooth will find a subset of https:// is available, as CoreBluetooth (Bluetooth LE) don't require https:// or https://.

Articles and Guides▲

  • https://

  • https://

Reference▲

  • https://

Logging Categories▲

The https:// module exports the following https://:

Logging Category

Description

qt.bluetooth

Enables logging of cross platform code path in https://

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.windows

Enables logging of the Windows implementation

Logging categories enable additional warning and debug output for https://. More detailed information about logging is found in https://. A quick way to enable all https:// logging is to add the following line to the main() function:

 
Sélectionnez
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));

Examples▲

  • QML

    • https://

    • https://

    • https://

    • https://

  • C++

    • https://

    • https://

Module Evolution▲

https:// lists important changes in the module API and functionality that were done for the Qt 6 series of Qt.

Licenses and Attributions▲

Qt Bluetooth is available under commercial licenses from http://. 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.

On Linux, Qt Bluetooth uses a separate executable, sdpscanner, to integrate with the official Linux bluetooth protocol stack BlueZ. BlueZ is available under the GNU General Public License, version 2.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.