Qt6 QML MapView使用有效Thunderforest API Key仍显示API Key Required水印
Qt6 QML中Thunderforest地图API Key不生效问题解决
你的代码中API Key配置存在参数名不匹配的问题,导致Thunderforest服务器未正确接收密钥,因此出现水印。以下是修正方案:
问题分析
Qt6的OSM插件对自定义瓦片服务的参数命名有明确规范,你当前使用的osm.mapping.custom.*系列参数并非正确的配置项,需要替换为官方指定的参数名。
修正后的代码
import QtQuick import QtLocation import QtPositioning MapView { anchors.fill: parent map.plugin: Plugin { name: "osm" // 配置Thunderforest瓦片服务器地址(不带协议头) PluginParameter { name: "osm.mapping.tile.host" value: "tile.thunderforest.com" } // 配置瓦片路径模板,包含样式占位符 PluginParameter { name: "osm.mapping.tile.path" value: "outdoors/{z}/{x}/{y}.png" } // 传递API Key参数 PluginParameter { name: "osm.mapping.tile.query_parameters" value: "apikey=THEAPIKEY" } } map.center: QtPositioning.coordinate(45.4642, 9.1900) map.zoomLevel: 14 }
额外检查项
- 确认Thunderforest账户中的API Key已启用对应瓦片服务(如outdoors样式),且账户状态正常无欠费
- 若使用Qt6早期版本,需确保
QtLocation模块已正确部署OSM插件(部分环境可能需要手动复制插件文件)
内容的提问来源于stack exchange,提问作者Jepessen
相关产品推荐
相关产品推荐

