QPermission Class

型付きパーミッションの不透明なラッパー。詳細...

ヘッダ #include <QPermissions>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
以来:Qt 6.5

パブリック関数

QPermission(const T &type)
Qt::PermissionStatus status() const
QMetaType type() const
std::optional<T> value() const

詳細説明

QPermission クラスはtyped permission の不透明なラッパーで、パーミッションのチェックやリクエスト時に使用されます。この型はパーミッションのチェックやリクエストの際に自動的に使用されるため、明示的に作成する必要はありません:

qApp->checkPermission(QCameraPermission{});

パーミッションを要求するとき、与えられたファンクタはQPermissionのインスタンスを渡されます:

qApp->requestPermission(QCameraPermission{}, [](const QPermission &permission) {
    if (permission.status() == Qt::PermissionStatus:Granted)
        takePhoto();
});

型付けされたオリジナルのパーミッションのプロパティを検査するには、value() 関数を使用します:

QLocationPermissionlocationPermission; 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();
}

タイプされたパーミッション

以下のパーミッションが利用できる:

QBluetoothPermission

Bluetooth周辺機器へのアクセス

QCalendarPermission

ユーザーのカレンダーへのアクセス

QCameraPermission

写真やビデオを撮影するためのカメラへのアクセス

QContactsPermission

ユーザーの連絡先へのアクセス

QLocationPermission

位置情報へのアクセス

QMicrophonePermission

音声のモニタリングや録音のためのマイクへのアクセス

アプリケーションのアクセス許可も参照してください

メンバー関数ドキュメント

template <typename T, QPermission::if_permission<T> = true> QPermission::QPermission(const T &type)

与えられたtyped permission type からパーミッションを構築する。

この型はパーミッションのチェックやリクエスト時に自動的に使用されるので、明示的に構築する必要はありません。

このコンストラクタは、Ttyped permission クラスの1つである場合にのみ、オーバーロード解決に参加します:

QBluetoothPermission

Bluetooth周辺機器へのアクセス

QCalendarPermission

ユーザーのカレンダーへのアクセス

QCameraPermission

写真やビデオを撮るためのカメラへのアクセス

QContactsPermission

ユーザーの連絡先へのアクセス

QLocationPermission

ユーザーの位置情報へのアクセス

QMicrophonePermission

音声のモニタリングや録音のためのマイクへのアクセス

Qt::PermissionStatus QPermission::status() const

パーミッションのステータスを返します。

QMetaType QPermission::type() const

パーミッションのタイプを返します。

template <typename T, QPermission::if_permission<T> = true> std::optional<T> QPermission::value() const

T 型のtyped permission を返し、このQPermission オブジェクトがstd::nullopt を含んでいない場合は を返す。

要求する型付き許可を動的に選択するには、type ()を使用する。

この関数は、Ttyped permission クラスの1つである場合にのみ、オーバーロード解決に参加します:

QBluetoothPermission

Bluetooth 周辺機器へのアクセス

QCalendarPermission

ユーザーのカレンダーへのアクセス

QCameraPermission

写真やビデオを撮るためのカメラへのアクセス

QContactsPermission

ユーザーの連絡先へのアクセス

QLocationPermission

ユーザーの位置情報へのアクセス

QMicrophonePermission

音声のモニタリングや録音のためのマイクへのアクセス

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.