工作原理 ChartView::zoomIn(rect rectangle)

How works ChartView::zoomIn(rect rectangle)

我想在 ChartView 中使用 rectang 区域缩放所选区域:

import QtQuick 2.7
import QtCharts 2.1

ChartView{
    id: chart
    width: 400
    height: 400

    ScatterSeries{
        markerSize: 10
        XYPoint{x: 1; y: 1}
        XYPoint{x: 2; y: 2}
        XYPoint{x: 5; y: 5}
    }

    Rectangle{
        id: rectang
        color: "black"
        opacity: 0.6
        visible: false
    }

    MouseArea{
        anchors.fill: parent
        hoverEnabled: true
        acceptedButtons: Qt.AllButtons

        onPressed: {rectang.x = mouseX; rectang.y = mouseY; rectangle.visible = true}
        onMouseXChanged: {rectang.width = mouseX - rectang.x}
        onMouseYChanged: {rectang.height = mouseY - rectang.y}
        onReleased: {
            chart.zoomIn(rectang); // something wrong with that line, it doesn't work
            rectang.visible = false
        } 
    }
}

你能告诉我如何正确使用 ChartView::zoomIn(rect rectangle) 吗?我希望缩放像 Zoom Line Example 中那样工作。简单 ChartView::zoomIn() 只需将中心缩放 2 倍即可。

这有帮助:

onReleased: {
        chart.zoomIn(Qt.rect(rectang.x, rectang.y, rectang.width, rectang.height))
        rectang.visible = false
}

我误以为rectRectangle是同一种类型