Location QML Type
位置类型保存位置数据。更多
Import Statement: | import QtPositioning |
属性
- address : Address
- boundingShape : geoshape
(since QtPositioning 6.2)
- coordinate : coordinate
- location : QGeoLocation
详细说明
位置类型代表人类意义上的地理 "位置"。它由一个特定的coordinate 、一个address 和一个bounding shape 组成。bounding shape 表示在查看该位置时建议显示的区域。
位置类型最常见的是作为搜索模型(如GeocodeModel )的内容。当GeocodeModel 返回为给定查询找到的位置列表时,它将这些位置表示为位置对象。
使用示例
下面的示例展示了一个简单的位置对象的声明:
Location { coordinate { latitude: -27.3 longitude: 153.1 } address: Address { ... } }
属性文档
address : Address |
该属性包含位置的地址,可用于检索位置的地址详细信息。
boundingShape : geoshape |
该属性包含显示位置时建议使用的区域。例如,建筑物的位置可能有一个以建筑物为中心的区域,但该区域要足够大,以显示其周围的地理环境。
注: 该属性的 changed() 信号目前仅在整个对象发生变化时发出,而不是仅在对象内容发生变化时发出。
注: 该属性在 Qt6 中引入,取代了 boundingBox 属性。它返回一个geoshape ,而不是georectangle 。使用QGeoShape::boundingGeoRectangle() 获取形状的边界georectangle 。
如果需要将返回的形状转换为特定类型,请使用geoshape 的type
属性以及QtPositioning 的方便方法,如QtPositioning.shapeToRectangle() 。
该属性在 QtPositioning 6.2 中引入。
coordinate : coordinate |
该属性保存位置的精确地理坐标,可用于检索位置的经度、纬度和高度。
注意: 该属性的 changed() 信号目前仅在整个对象发生变化时发出,而不是仅在对象内容发生变化时发出。
location : QGeoLocation |
有关如何使用此属性在 C++ 和 QML之间建立接口的详情,请参阅"C++ 和 QML 代码之间的接口"("Interfaces between C++ and QML Code")。
注意: 该属性会更新整个地理位置信息,因此使用该属性会破坏所有其他属性的绑定。
© 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.