class QPermission#

An opaque wrapper of a typed permission. More

New in version 6.5.

Synopsis#

Methods#

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 a typed 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:

PySide6.QtCore.QCameraPermission

Access the camera for taking pictures or videos.

PySide6.QtCore.QMicrophonePermission

Access the microphone for monitoring or recording sound.

PySide6.QtCore.QBluetoothPermission

Access Bluetooth peripherals.

PySide6.QtCore.QLocationPermission

Access the user’s location.

PySide6.QtCore.QContactsPermission

Access the user’s contacts.

PySide6.QtCore.QCalendarPermission

Access the user’s calendar.

See also

Application Permissions

__init__()#
status()#
Return type:

PermissionStatus

Returns the status of the permission.

type()#
Return type:

QMetaType

Returns the type of the permission.