QLocationPermission Class

Access the user's location. 更多...

头: #include <QPermissions>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 6.5

公共类型

enum Accuracy { Approximate, Precise }
enum 可用性 { WhenInUse, Always }

公共函数

QLocationPermission::Accuracy accuracy () const
QLocationPermission::Availability availability () const
void setAccuracy (QLocationPermission::Accuracy accuracy )
void setAvailability (QLocationPermission::Availability availability )

详细描述

By default the request is for approximate accuracy, and only while the application is in use. Use setAccuracy () 和/或 setAvailability () to override the default.

要求

To request this permission at runtime, the following platform specific usage declarations have to be made at build time:

平台 类型
macOS Usage description NSLocationUsageDescription
iOS Usage description NSLocationWhenInUseUsageDescription ,和 NSLocationAlwaysAndWhenInUseUsageDescription if requesting QLocationPermission::Always
Android uses-permission

注意: QLocationPermission::Always uses-permission string has to be combined with one or both of QLocationPermission::Precise and QLocationPermission::Approximate strings.

Please see the individual usage declaration types for how to add them to your project.

另请参阅 QPermission , QCoreApplication::requestPermission (), QCoreApplication::checkPermission (),和 应用程序权限 .

成员类型文档编制

enum QLocationPermission:: Accuracy

This enum is used to control the accuracy of the location data.

常量 描述
QLocationPermission::Approximate 0 An approximate location is requested.
QLocationPermission::Precise 1 A precise location is requested.

enum QLocationPermission:: 可用性

This enum is used to control the availability of the location data.

常量 描述
QLocationPermission::WhenInUse 0 The location is only available only when the application is in use.
QLocationPermission::Always 1 The location is available at all times, including when the application is in the background.

成员函数文档编制

QLocationPermission::Accuracy QLocationPermission:: accuracy () const

Returns the accuracy of the request.

另请参阅 setAccuracy ().

QLocationPermission::Availability QLocationPermission:: availability () const

Returns the availability of the request.

另请参阅 setAvailability ().

void QLocationPermission:: setAccuracy ( QLocationPermission::Accuracy accuracy )

设置期望 accuracy of the request.

另请参阅 accuracy ().

void QLocationPermission:: setAvailability ( QLocationPermission::Availability availability )

设置期望 availability of the request.

另请参阅 availability ().