本页内容

地图与导航(C++)

“地图与导航”提供了用于地理编码(根据街道地址查找地理坐标)和导航(包括驾车和步行路线)的 C++ 实用工具。

目前尚无法通过 C++ 与地图进行交互。地图应用程序必须使用“地图与导航(QML)”API。

地理编码

在 C++ 中,地址转坐标的查询通过 `QGeoCodingManager ` 类的 `geocode()` 方法实现。对于坐标转地址的查询,可使用同一类中的 `reverseGeocode()` 方法。可通过 `QGeoServiceProvider` 获取 `QGeoCodingManager ` 的实例。

关键类

QGeoServiceProvider提供一个可直接使用的QGeoCodingManager 实例。
QGeoCodingManager接受查询并返回QGeoCodeReply 对象。
QGeoCodeReply包含地理编码查询的结果。

在 C++ 中,路线查询是通过QGeoRoutingManager 类的calculate() 方法来执行的。返回的路线响应可能包含通往同一目的地的多条路线。

关键类

QGeoServiceProvider提供一个可直接使用的QGeoCodingManager 实例。
QGeoRoutingManager接受查询并生成QGeoRouteReply 对象。
QGeoRouteReply包含路由查询的结果。
QGeoRoute包含有关某条路线的信息。

© 2026 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.