QBluetoothPermission Class

Access Bluetooth peripherals. 更多...

頭: #include <QPermissions>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 6.5

公共類型

(從 6.6 起) enum CommunicationMode { Access, Advertise, Default }
flags CommunicationModes

公共函數

(從 6.6 起) QBluetoothPermission::CommunicationModes communicationModes () const
(從 6.6 起) void setCommunicationModes (QBluetoothPermission::CommunicationModes modes )

詳細描述

要求

To request this permission at runtime, the following platform specific usage declarations have to be made at build time:

平颱 類型
Apple Usage description NSBluetoothAlwaysUsageDescription
Android uses-permission Up to Android 11 (API Level < 31):
  • android.permission.BLUETOOTH
  • android.permission.ACCESS_FINE_LOCATION

Starting from Android 12 (API Level >= 31):

  • android.permission.BLUETOOTH_ADVERTISE
  • android.permission.BLUETOOTH_CONNECT
  • android.permission.BLUETOOTH_SCAN

Please see the individual usage declaration types for how to add them to your project.

注意: Since Qt 6.8.1, the ACCESS_FINE_LOCATION permission is no longer requested if API Level >= 31. This may limit some Bluetooth scan results . Users needing these results need to request the location permission separately (see precise location ) and ensure that BLUETOOTH_SCAN permission doesn't have the android:usesPermissionFlags="neverForLocation" attribute set. For setting and customizing permissions in the application manifest, see this guide .

另請參閱 QPermission , QCoreApplication::requestPermission (), QCoreApplication::checkPermission (),和 應用程序權限 .

成員類型文檔編製

[since 6.6] enum QBluetoothPermission:: CommunicationMode
flags QBluetoothPermission:: CommunicationModes

This enum is used to control the allowed Bluetooth communication modes.

常量 描述
QBluetoothPermission::Access 0x01 Allow this device to access other Bluetooth devices. This includes scanning for nearby devices and connecting to them.
QBluetoothPermission::Advertise 0x02 Allow other Bluetooth devices to discover this device.
QBluetoothPermission::Default Access | Advertise This configuration is used by default.

注意: The fine-grained permissions are currently supported only on Android 12 and newer. On older Android versions, as well as on Apple operating systems, any mode results in full Bluetooth access.

該枚舉在 Qt 6.6 引入。

The CommunicationModes type is a typedef for QFlags <CommunicationMode>. It stores an OR combination of CommunicationMode values.

成員函數文檔編製

[since 6.6] QBluetoothPermission::CommunicationModes QBluetoothPermission:: communicationModes () const

Returns the allowed Bluetooth communication modes.

該函數在 Qt 6.6 引入。

另請參閱 setCommunicationModes ().

[since 6.6] void QBluetoothPermission:: setCommunicationModes ( QBluetoothPermission::CommunicationModes modes )

Sets the allowed Bluetooth communication modes to modes .

注意: A default-constructed instance of CommunicationModes has no sense, so an attempt to set such a mode will raise a qWarning() and fall back to using the 默認 模式。

該函數在 Qt 6.6 引入。

另請參閱 communicationModes ().