PySide6.QtCore.QPermission¶
- class QPermission¶
An opaque wrapper of a typed permission. More…
Added in version 6.5.
Synopsis¶
Methods¶
def
__init__()
def
status()
def
type()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
The
QPermission
class is an opaque wrapper of atyped permission
, used when checking or requesting permissions. You do not need to construct this type explicitly, as the type is automatically used when checking or requesting permissions:qApp->checkPermission(QCameraPermission{});
When requesting permissions, the given functor will be passed an instance of a
QPermission
, which can be used to check the result of the request:qApp->requestPermission(QCameraPermission{}, [](const QPermission &permission) { if (permission.status() == Qt::PermissionStatus:Granted) takePhoto(); });
To inspect the properties of the original, typed permission, use the
value()
function:QLocationPermission locationPermission; locationPermission.setAccuracy(QLocationPermission::Precise); qApp->requestPermission(locationPermission, this, &LocationWidget::permissionUpdated);
void LocationWidget::permissionUpdated(const QPermission &permission) { if (permission.status() != Qt::PermissionStatus:Granted) return; auto locationPermission = permission.value<QLocationPermission>(); if (!locationPermission || locationPermission->accuracy() != QLocationPermission::Precise) return; updatePreciseLocation(); }
Typed Permissions¶
The following permissions are available:
Access the camera for taking pictures or videos.
Access the microphone for monitoring or recording sound.
Access Bluetooth peripherals.
Access the user’s location.
Access the user’s contacts.
Access the user’s calendar.
See also
Application Permissions
- __init__()¶
- status()¶
- Return type:
Returns the status of the permission.
Returns the type of the permission.