微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Qt Qml ChartView 左对齐

如何解决Qt Qml ChartView 左对齐

我使用 Qt Quick Qml 在 ChartView 下面。

Rectangle {
    anchors.left: parent.left
    anchors.leftMargin: 10
    anchors.top: parent.top
    anchors.topMargin: 10

    width: parent.width
    height: 100
        
    ChartView {
        id: myChartView
        anchors.left: parent.left
        width: parent.width
        height: parent.height

        // For removing extra padding around chart
        margins { top: 0; bottom: 0; left: 0; right: 0 }
        plotArea: Qt.rect(0,parent.width,parent.height)
        antialiasing: true

        Lineseries {
            id: mySeries
            name: "mySeries"
            axisX: myAxisX
            axisY: myAxisY
            width: 2

            XYPoint { x: 0; y: 0 }
            XYPoint { x: 5; y: 2 }
        }

        ValueAxis {
            id: myAxisX
            min: 0
            max: 20
        }

        ValueAxis {
            id: myAxisY
            min: 0
            max: 10
        }
    }        
}

我面临的问题是我的图表 0,0 从屏幕/父级的某个中心开始。
如果我将 myAxisX.max 更新为大约 300 或 400,那么我会看到 0,0 向左移动。
但我想始终从与 myAxisX.max 无关的左下角开始我的图表。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。