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 COMPONENTS Positioning REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Positioning)
qmake: QT += positioning
Since: Qt 5.2

公共类型

enum Attribute { Direction, GroundSpeed, VerticalSpeed, MagneticVariation, HorizontalAccuracy, VerticalAccuracy }

公共函数

  QGeoPositionInfo (QGeoPositionInfo && other )
  QGeoPositionInfo (const QGeoPositionInfo & other )
  QGeoPositionInfo (const QGeoCoordinate & coordinate , const QDateTime & timestamp )
  QGeoPositionInfo ()
QGeoPositionInfo & operator= (QGeoPositionInfo && other )
QGeoPositionInfo & operator= (const QGeoPositionInfo & other )
  ~QGeoPositionInfo ()
qreal 属性 (QGeoPositionInfo::Attribute 属性 ) const
QGeoCoordinate coordinate () const
bool hasAttribute (QGeoPositionInfo::Attribute 属性 ) const
bool isValid () const
void removeAttribute (QGeoPositionInfo::Attribute 属性 )
void setAttribute (QGeoPositionInfo::Attribute 属性 , qreal value )
void setCoordinate (const QGeoCoordinate & coordinate )
void setTimestamp (const QDateTime & timestamp )
QDateTime timestamp () const
bool operator!= (const QGeoPositionInfo & lhs , const QGeoPositionInfo & rhs )
QDataStream & operator<< (QDataStream & stream , const QGeoPositionInfo & info )
QDataStream & operator<< (QDataStream & stream , QGeoPositionInfo::Attribute attr )
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:: Attribute

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.

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

成员函数文档编制

[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 引入。

QGeoPositionInfo:: QGeoPositionInfo (const QGeoPositionInfo & other )

Creates a QGeoPositionInfo with the values of other .

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

Creates a QGeoPositionInfo for the given coordinate and timestamp .

QGeoPositionInfo:: QGeoPositionInfo ()

Creates an invalid QGeoPositionInfo object.

另请参阅 isValid ().

[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 )

Assigns the values from other 到此 QGeoPositionInfo .

QGeoPositionInfo:: ~QGeoPositionInfo ()

销毁 QGeoPositionInfo 对象。

qreal QGeoPositionInfo:: 属性 ( QGeoPositionInfo::Attribute 属性 ) const

Returns the value of the specified 属性 as a qreal value.

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 属性 ) const

返回 true 若指定 属性 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 属性 )

移除指定 属性 and its value.

void QGeoPositionInfo:: setAttribute ( QGeoPositionInfo::Attribute 属性 , qreal value )

Sets the value for 属性 to value .

另请参阅 属性 ().

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 .

timestamp must be in UTC time.

另请参阅 timestamp ().

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 ().

相关非成员

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 , const QGeoPositionInfo & info )

写入给定 info 到指定 stream .

另请参阅 序列化 Qt 数据类型 .

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

写入给定 attr enumeration to the specified 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 数据类型 .