QML地图未缩放到光标

时间:2020-08-05 13:27:53

标签: c++ qt qml

我创建了一个QML地图,当通过滚动缩放时,缩放到地图的中心,而不是缩放到光标位置。从另一个SO答案中,我得出的结论是,这应该是默认行为,但对我而言不是这样。

import QtQuick 2.5
import QtQuick.Window 2.0
import QtQuick.Controls 1.4
import QtLocation 5.5
import QtPositioning 5.5

ApplicationWindow {
    title: "Mapper"
    id: mapWindow
    x: Screen.width / 2 - width / 2
    y: Screen.height / 2 - height / 2
    width: 1400
    height: 800
    visible: true
    color: "#0b2f5c"

    Map
    {
        id: basemap
        objectName: "basemap"
        property string inputStr: "import QtQuick 2.0; import QtLocation 5.0; import QtPositioning 5.0; "
        anchors.fill: parent
        anchors.rightMargin: 300
        anchors.leftMargin: 25
        anchors.topMargin: 50
        anchors.bottomMargin: 50
        plugin: Plugin
        {
            name: "osm"
            PluginParameter
            {
                name: "osm.mapping.custom.host"
                value: "https://a.tile.openstreetmap.org/"
            }
        }
        activeMapType: supportedMapTypes[supportedMapTypes.length - 1]
        center: QtPositioning.coordinate(0, 0)
        zoomLevel: 2
        minimumZoomLevel: 2
    }
}

我正在用C ++中的QQmlApplicationEngine启动窗口

QQmlApplicationEngine* engine = new QQmlApplicationEngine(QUrl("<path to file>"));
QObject* topLevel = mEngine->rootObjects().value(0);
QQuickWindow* window = qobject_cast<QQuickWindow*>(mTopLevel);

window->show();

这是怎么回事?预先感谢!

0 个答案:

没有答案