如何一键平移QML地图并开始在其上拖动鼠标指针?

How to pan QML Map as soon as one press and start dragging mouse pointer on it?

我启用了这样的手势:

gesture.enabled: true

但是当我按下并开始移动鼠标指针时地图并没有开始平移,而是当我已经将鼠标指针拖动超过 10 像素左右时地图开始平移!

谁能帮我在鼠标指针开始拖动时立即开始平移地图,而不是等待 10 个左右的像素拖动等待?

如果the MapGestureArea source code is analyzed then it is observed that the threshold used depends on QStyleHints::startDragDistance:

bool QQuickGeoMapGestureArea::canStartPan()
{
    if (m_allPoints.count() == 0 || (m_acceptedGestures & PanGesture) == 0
            || (m_mousePoint && m_mousePoint->state() == Qt::TouchPointReleased)) // mouseReleaseEvent handling does not clear m_mousePoint, only ungrabMouse does -- QTBUG-66534
        return false;

    // Check if thresholds for normal panning are met.
    // (normal panning vs flicking: flicking will start from mouse release event).
    <b>const int startDragDistance = qApp->styleHints()->startDragDistance() * 2;</b>
    QPointF p1 = mapFromScene(m_allPoints.at(0).scenePos());
    int dyFromPress = int(p1.y() - m_sceneStartPoint1.y());
    int dxFromPress = int(p1.x() - m_sceneStartPoint1.x());
    if ((qAbs(dyFromPress) >= startDragDistance || qAbs(dxFromPress) >= startDragDistance))
        return true;
    return false;
}

所以解决方案是修改 属性(startDragDistance 的 setter 方法没有记录,可能是一个错误):

# ...
QGuiApplication app(argc, argv);
<b>app.styleHints()->setStartDragDistance(0);</b>
# ...