QBluetoothPermission Class
Access Bluetooth peripherals. More...
Header: | #include <QPermissions> |
Public Types
enum | CommunicationMode { Access, Advertise, Default } |
flags | CommunicationModes |
Public Functions
CommunicationModes | communicationModes() const |
void | setCommunicationModes(CommunicationModes modes) |
Detailed Description
Requirements
To request this permission at runtime, the following platform specific usage declarations have to be made at build time:
Platform | Type | |
---|---|---|
Apple | Usage description | NSBluetoothAlwaysUsageDescription |
Android | uses-permission | Up to Android 11 (API Level < 31):
Starting from Android 12 (API Level >= 31):
|
Please see the individual usage declaration types for how to add them to your project.
Note: Currently on Android the android.permission.ACCESS_FINE_LOCATION
permission is requested together with Bluetooth permissions. This is required for Bluetooth to work properly, unless the application provides a strong assertion in the application manifest that it does not use Bluetooth to derive a physical location. This permission coupling may change in future.
\inmodule
QtCore \ingroup
permissions \since
6.5
See also QPermission, QCoreApplication::requestPermission(), QCoreApplication::checkPermission(), and Application Permissions.
Member Type Documentation
enum QBluetoothPermission::CommunicationMode
flags QBluetoothPermission::CommunicationModes
\since
6.6
This enum is used to control the allowed Bluetooth communication modes.
Constant | Value | Description |
---|---|---|
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. |
Note: 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.
Note: For now the Access
mode on Android also requests the precise location permission. This permission coupling may change in the future.
The CommunicationModes type is a typedef for QFlags<CommunicationMode>. It stores an OR combination of CommunicationMode values.
Member Function Documentation
CommunicationModes QBluetoothPermission::communicationModes() const
\since
6.6
Returns the allowed Bluetooth communication modes.
See also setCommunicationModes().
void QBluetoothPermission::setCommunicationModes(CommunicationModes modes)
\since
6.6
Sets the allowed Bluetooth communication modes to modes.
Note: 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 Default mode.
See also communicationModes().