PySide6.QtBluetooth¶
- PySide6.QtBluetooth.QBluetooth
- PySide6.QtBluetooth.QBluetoothAddress
- PySide6.QtBluetooth.QBluetoothDeviceDiscoveryAgent
- PySide6.QtBluetooth.QBluetoothDeviceInfo
- PySide6.QtBluetooth.QBluetoothHostInfo
- PySide6.QtBluetooth.QBluetoothLocalDevice
- PySide6.QtBluetooth.QBluetoothServer
- PySide6.QtBluetooth.QBluetoothServiceDiscoveryAgent
- PySide6.QtBluetooth.QBluetoothServiceInfo
- PySide6.QtBluetooth.QBluetoothSocket
- PySide6.QtBluetooth.QBluetoothUuid
- PySide6.QtBluetooth.QLowEnergyAdvertisingData
- PySide6.QtBluetooth.QLowEnergyAdvertisingParameters
- PySide6.QtBluetooth.QLowEnergyCharacteristic
- PySide6.QtBluetooth.QLowEnergyCharacteristicData
- PySide6.QtBluetooth.QLowEnergyConnectionParameters
- PySide6.QtBluetooth.QLowEnergyController
- PySide6.QtBluetooth.QLowEnergyDescriptor
- PySide6.QtBluetooth.QLowEnergyDescriptorData
- PySide6.QtBluetooth.QLowEnergyService
- PySide6.QtBluetooth.QLowEnergyServiceData
详细描述¶
Qt 蓝牙实现了蓝牙设备之间的连接。
蓝牙API提供了支持蓝牙设备之间的连接。
目前,API在以下平台上得到支持:
API 功能
安卓
iOS
Linux (BlueZ 5.x)
Windows 版 Qt
经典蓝牙
x
x
x
x
蓝牙低功耗中心
x
x
x
x
x
蓝牙低功耗外设
x
x
x
x
蓝牙低功耗广告与扫描
Qt 5.14 添加了一个原生的 Win32 端口,支持在 Windows 7 或更新版本上的经典蓝牙,以及在 Windows 8 或更新版本上的蓝牙低功耗(BLE)。它必须在构建时通过配置选项 -native-win32-bluetooth 启用。如果未设置此选项且 Win32 目标平台支持所需的 UWP API(最低要求是 Windows 10 版本 1507,自 Windows 10 版本 1607 以来服务发现略有改进),则默认使用 UWP 后端。
概述¶
蓝牙是一种短距离(小于100米)无线技术。它具有相当高的数据传输速率,达到2.1 Mbit/s,这使得它非常适合在设备之间传输数据。蓝牙连接基于基本的设备管理,例如扫描设备、收集设备信息以及在设备之间交换数据。
Qt Bluetooth 支持用于客户端/中心角色的蓝牙低功耗开发。更多详细信息可以在蓝牙低功耗概述部分找到。
使用模块¶
要包含模块类的定义,请使用以下指令:
import PySide6.QtBluetooth
macOS 特定¶
macOS上的蓝牙API需要一种特定类型的事件分发器,这在Qt中会导致对QGuiApplication
的依赖。然而,你可以设置环境变量QT_EVENT_DISPATCHER_CORE_FOUNDATION=1
来规避这个问题。
不使用经典蓝牙的应用程序会发现QtBluetooth的一个子集是可用的,因为CoreBluetooth(蓝牙低功耗)不需要QApplication
或QGuiApplication
。
指南¶
日志类别¶
QtBluetooth 模块导出了以下 logging categories
:
日志类别
描述
qt.bluetooth
启用QtBluetooth中跨平台代码路径的日志记录
qt.bluetooth.android
启用Android实现的日志记录
qt.bluetooth.bluez
启用BLuez/Linux实现的日志记录
qt.bluetooth.ios
启用iOS实现的日志记录
qt.bluetooth.osx
启用macOS实现的日志记录
qt.bluetooth.windows
启用Qt for Windows实现的日志记录
日志类别可用于为QtBluetooth启用额外的警告和调试输出。有关日志记录的更详细信息可以在QLoggingCategory
中找到。启用所有QtBluetooth日志记录的快速方法是将以下行添加到main()
函数中:
QLoggingCategory.setFilterRules("qt.bluetooth* = true")
班级列表¶
A |
|||||
B |
|||||
L |
|||||
S |