이 페이지에서

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()
QPermission(const T &type)
Qt::PermissionStatus status() const
QMetaType type() const
std::optional<T> value() const

상세 설명

QPermission 클래스는 권한을 확인하거나 요청할 때 사용되는 typed permission 의 불투명한 래퍼입니다. 권한을 확인하거나 요청할 때 이 유형이 자동으로 사용되므로, 이 유형을 명시적으로 생성할 필요는 없습니다:

qApp->checkPermission(QCameraPermission{});

권한을 요청할 때, 지정된 펑터(functor)에는 QPermission 인스턴스가 전달되며, 이를 사용하여 요청 결과를 확인할 수 있습니다:

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

원본의 타입이 지정된 권한의 속성을 확인하려면 ` value()` 함수를 사용하십시오:

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

유형별 권한

다음과 같은 권한을 사용할 수 있습니다:

QBluetoothPermission

블루투스 주변기기 액세스

QCalendarPermission

사용자의 캘린더에 접근

QCameraPermission

사진이나 동영상을 촬영하기 위해 카메라에 접근

QContactsPermission

사용자의 연락처에 접근

QLocationPermission

사용자의 위치 정보에 접근

QMicrophonePermission

소리 모니터링 또는 녹음을 위한 마이크 접근

‘앱 권한’항목도 참조하십시오 .

멤버 함수 문서

[explicit noexcept default] QPermission::QPermission()

QPermission 의 인스턴스를 기본 생성합니다.

template <typename T> requires if_permission<T> QPermission::QPermission(const T &type)

주어진 typed permission type 에서 권한을 생성합니다.

권한을 확인하거나 요청할 때 이 타입이 자동으로 사용되므로, 이 타입을 명시적으로 생성할 필요는 없습니다.

제약 조건

T 가 다음 typed permission 클래스 중 하나인 경우에만 오버로드 해결에 참여합니다:

QBluetoothPermission

블루투스 주변 장치에 액세스

QCalendarPermission

사용자의 캘린더에 액세스

QCameraPermission

사진이나 동영상 촬영을 위해 카메라에 접근

QContactsPermission

사용자의 연락처에 접근

QLocationPermission

사용자의 위치 정보에 접근

QMicrophonePermission

소리 모니터링 또는 녹음을 위한 마이크 접근

Qt::PermissionStatus QPermission::status() const

권한 상태를 반환합니다.

QMetaType QPermission::type() const

권한의 유형을 반환합니다.

template <typename T> requires if_permission<T> std::optional<T> QPermission::value() const

T 유형의 typed permission 를 반환하거나, 이 QPermission 객체에 해당 권한이 포함되어 있지 않은 경우 std::nullopt 을 반환합니다.

요청할 유형 지정 권한을 동적으로 선택하려면 ` type()`를 사용하십시오.

제약 조건

T 가 다음 typed permission 클래스 중 하나인 경우에만 오버로드 해결에 참여합니다:

QBluetoothPermission

블루투스 주변기기 액세스

QCalendarPermission

사용자의 캘린더에 액세스

QCameraPermission

사진 또는 동영상 촬영을 위한 카메라에 액세스

QContactsPermission

사용자의 연락처에 접근

QLocationPermission

사용자의 위치 정보에 접근

QMicrophonePermission

소리 모니터링 또는 녹음을 위해 마이크에 접근

© 2026 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.