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() 함수를 사용합니다:
QLocationPermission locationPermission; locationPermission.setAccuracy(QLocationPermission::정확도);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(); }
입력된 권한
다음 권한을 사용할 수 있습니다:
Bluetooth 주변 장치 액세스 | |
사용자의 캘린더에 액세스 | |
사진 또는 동영상 촬영을 위해 카메라에 액세스 | |
사용자의 연락처에 액세스 | |
사용자의 위치 액세스 | |
사운드 모니터링 또는 녹음을 위한 마이크 액세스 |
애플리케이션 권한도참조하세요 .
멤버 기능 문서
template <typename T, QPermission::if_permission<T> = true> QPermission::QPermission(const T &type)
주어진 typed permission type 에서 권한을 구성합니다.
이 유형은 권한을 확인하거나 요청할 때 자동으로 사용되므로 명시적으로 이 유형을 생성할 필요가 없습니다.
이 생성자는 T
가 typed permission 클래스 중 하나인 경우에만 과부하 해결에 참여합니다:
블루투스 주변 장치에 액세스 | |
사용자의 캘린더에 액세스 | |
사진 또는 동영상 촬영을 위해 카메라에 액세스 | |
사용자의 연락처에 액세스 | |
사용자의 위치 액세스 | |
사운드 모니터링 또는 녹음을 위한 마이크 액세스 |
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()를 사용합니다.
이 함수는 T
가 typed permission 클래스 중 하나인 경우에만 과부하 해결에 참여합니다:
블루투스 주변 장치에 액세스 | |
사용자의 캘린더에 액세스 | |
사진 또는 동영상 촬영을 위해 카메라에 액세스 | |
사용자의 연락처에 액세스 | |
사용자의 위치 액세스 | |
사운드 모니터링 또는 녹음을 위한 마이크 액세스 |
© 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.