QGeoPositionInfo Class

The QGeoPositionInfo class contains information gathered on a global position, direction and velocity at a particular point in time. 更多...

頭: #include <QGeoPositionInfo>
CMake: find_package(Qt6 REQUIRED COMPONENTS Positioning)
target_link_libraries(mytarget PRIVATE Qt6::Positioning)
qmake: QT += positioning

公共類型

enum 屬性 { Direction, GroundSpeed, VerticalSpeed, MagneticVariation, HorizontalAccuracy, …, DirectionAccuracy }

公共函數

QGeoPositionInfo ()
QGeoPositionInfo (const QGeoCoordinate & coordinate , const QDateTime & timestamp )
QGeoPositionInfo (const QGeoPositionInfo & other )
(從 6.2 起) QGeoPositionInfo (QGeoPositionInfo && other )
~QGeoPositionInfo ()
qreal attribute (QGeoPositionInfo::Attribute attribute ) const
QGeoCoordinate coordinate () const
bool hasAttribute (QGeoPositionInfo::Attribute attribute ) const
bool isValid () const
void removeAttribute (QGeoPositionInfo::Attribute attribute )
void setAttribute (QGeoPositionInfo::Attribute attribute , qreal value )
void setCoordinate (const QGeoCoordinate & coordinate )
void setTimestamp (const QDateTime & timestamp )
(從 6.2 起) void swap (QGeoPositionInfo & other )
QDateTime timestamp () const
(從 6.2 起) QGeoPositionInfo & operator= (QGeoPositionInfo && other )
QGeoPositionInfo & operator= (const QGeoPositionInfo & other )
bool operator!= (const QGeoPositionInfo & lhs , const QGeoPositionInfo & rhs )
QDataStream & operator<< (QDataStream & stream , QGeoPositionInfo::Attribute attr )
QDataStream & operator<< (QDataStream & stream , const QGeoPositionInfo & info )
bool operator== (const QGeoPositionInfo & lhs , const QGeoPositionInfo & rhs )
QDataStream & operator>> (QDataStream & stream , QGeoPositionInfo & info )
QDataStream & operator>> (QDataStream & stream , QGeoPositionInfo::Attribute & attr )

詳細描述

A QGeoPositionInfo contains, at a minimum, a geographical coordinate and a timestamp. It may also have heading and speed measurements as well as estimates of the accuracy of the provided data.

另請參閱 QGeoPositionInfoSource .

成員類型文檔編製

enum QGeoPositionInfo:: 屬性

Defines the attributes for positional information.

常量 描述
QGeoPositionInfo::Direction 0 The bearing measured in degrees clockwise from true north to the direction of travel.
QGeoPositionInfo::GroundSpeed 1 The ground speed, in meters/sec.
QGeoPositionInfo::VerticalSpeed 2 The vertical speed, in meters/sec.
QGeoPositionInfo::MagneticVariation 3 The angle between the horizontal component of the magnetic field and true north, in degrees. Also known as magnetic declination. A positive value indicates a clockwise direction from true north and a negative value indicates a counter-clockwise direction.
QGeoPositionInfo::HorizontalAccuracy 4 The accuracy of the provided latitude-longitude value, in meters.
QGeoPositionInfo::VerticalAccuracy 5 The accuracy of the provided altitude value, in meters.
QGeoPositionInfo::DirectionAccuracy 6 The accuracy of the provided bearing, in degrees. This attribute is available only on Android (API level 26 or above) and macOS/iOS. See corresponding Android and Apple 文檔編製瞭解更多細節。

NMEA protocol also suggests another type of accuracy - PositionAccuracy, which is a 3D accuracy value. Qt does not provide a separate attribute for it. If you need this value, you can calculate it based on the following formula:

PositionAccuracy 2 = HorizontalAccuracy 2 + VerticalAccuracy 2

成員函數文檔編製

QGeoPositionInfo:: QGeoPositionInfo ()

Creates an invalid QGeoPositionInfo object.

另請參閱 isValid ().

QGeoPositionInfo:: QGeoPositionInfo (const QGeoCoordinate & coordinate , const QDateTime & timestamp )

Creates a QGeoPositionInfo for the given coordinate and timestamp .

QGeoPositionInfo:: QGeoPositionInfo (const QGeoPositionInfo & other )

Creates a QGeoPositionInfo with the values of other .

[noexcept, since 6.2] QGeoPositionInfo:: QGeoPositionInfo ( QGeoPositionInfo && other )

Creates a QGeoPositionInfo object by moving from other .

Note that a moved-from QGeoPositionInfo can only be destroyed or assigned to. The effect of calling other functions than the destructor or one of the assignment operators is undefined.

該函數在 Qt 6.2 引入。

[noexcept] QGeoPositionInfo:: ~QGeoPositionInfo ()

銷毀 QGeoPositionInfo 對象。

qreal QGeoPositionInfo:: 屬性 ( QGeoPositionInfo::Attribute attribute ) const

返迴值為指定 attribute 如 qreal 值。

Returns NaN if the value has not been set.

函數 hasAttribute () should be used to determine whether or not a value has been set for an attribute.

另請參閱 hasAttribute () 和 setAttribute ().

QGeoCoordinate QGeoPositionInfo:: coordinate () const

Returns the coordinate for this position.

Returns an invalid coordinate if no coordinate has been set.

另請參閱 setCoordinate ().

bool QGeoPositionInfo:: hasAttribute ( QGeoPositionInfo::Attribute attribute ) const

返迴 true 若指定 attribute is present for this QGeoPositionInfo 對象。

bool QGeoPositionInfo:: isValid () const

返迴 true 若 timestamp () 和 coordinate () values are both valid.

另請參閱 QGeoCoordinate::isValid () 和 QDateTime::isValid ().

void QGeoPositionInfo:: removeAttribute ( QGeoPositionInfo::Attribute attribute )

移除指定 attribute 及其值。

void QGeoPositionInfo:: setAttribute ( QGeoPositionInfo::Attribute attribute , qreal value )

設置值為 attribute to value .

另請參閱 attribute ().

void QGeoPositionInfo:: setCoordinate (const QGeoCoordinate & coordinate )

Sets the coordinate for this position to coordinate .

另請參閱 coordinate ().

void QGeoPositionInfo:: setTimestamp (const QDateTime & timestamp )

Sets the date and time at which this position was reported to timestamp .

The timestamp must be in UTC time.

另請參閱 timestamp ().

[noexcept, since 6.2] void QGeoPositionInfo:: swap ( QGeoPositionInfo & other )

Swaps this position information with other 。此操作很快且從不失敗。

該函數在 Qt 6.2 引入。

QDateTime QGeoPositionInfo:: timestamp () const

Returns the date and time at which this position was reported, in UTC time.

Returns an invalid QDateTime if no date/time value has been set.

另請參閱 setTimestamp ().

[noexcept, since 6.2] QGeoPositionInfo &QGeoPositionInfo:: operator= ( QGeoPositionInfo && other )

Move-assigns the values from other 到此對象。

Note that a moved-from QGeoPositionInfo can only be destroyed or assigned to. The effect of calling other functions than the destructor or one of the assignment operators is undefined.

該函數在 Qt 6.2 引入。

QGeoPositionInfo &QGeoPositionInfo:: operator= (const QGeoPositionInfo & other )

賦值值從 other 到此 QGeoPositionInfo .

相關非成員

bool operator!= (const QGeoPositionInfo & lhs , const QGeoPositionInfo & rhs )

返迴 true if any of the lhs object's values are not the same as those of rhs . Otherwise returns false .

QDataStream & operator<< ( QDataStream & stream , QGeoPositionInfo::Attribute attr )

寫入給定 attr enumeration to the specified stream .

另請參閱 序列化 Qt 數據類型 .

QDataStream & operator<< ( QDataStream & stream , const QGeoPositionInfo & info )

寫入給定 info 到指定 stream .

另請參閱 序列化 Qt 數據類型 .

bool operator== (const QGeoPositionInfo & lhs , const QGeoPositionInfo & rhs )

返迴 true if all of the lhs object's values are the same as those of rhs . Otherwise returns false .

QDataStream & operator>> ( QDataStream & stream , QGeoPositionInfo & info )

Reads a coordinate from the specified stream 進給定 info .

另請參閱 序列化 Qt 數據類型 .

QDataStream & operator>> ( QDataStream & stream , QGeoPositionInfo::Attribute & attr )

Reads an attribute enumeration from the specified stream info the given attr .

另請參閱 序列化 Qt 數據類型 .