我QT Charts
用来在 UI 上绘制数据,我的绘图将是实时的,X 和 Y 轴将依次增加,因为我需要链接scrollBar
到图表。由于ChartView
没有内置scrollbar
的 in Flickable
,我想知道如何在 QML 中做到这一点,以下是代码:
import QtQuick 2.6
import QtQuick.Window 2.2
import QtCharts 2.0
import QtQuick.Controls 2.2
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
ChartView {
id:chartview
width: 400
height: 300
antialiasing: true
LineSeries {
name: "LineSeries"
axisX: valueAxis
XYPoint { x: 0; y: 0.0 }
XYPoint { x: 1.1; y: 3.2 }
XYPoint { x: 1.9; y: 2.4 }
XYPoint { x: 2.1; y: 2.1 }
XYPoint { x: 2.9; y: 2.6 }
XYPoint { x: 3.4; y: 2.3 }
XYPoint { x: 200.1; y: 3.1 }
}
ValueAxis {
id: valueAxis
min: 0
max: 20
tickCount: 12
labelFormat: "%.0f"
}
}
ScrollBar{
id:sBarHor
visible:true
width: chartview.width
height:30
anchors.top:chartview.bottom
orientation: Qt.Horizontal
contentItem: Rectangle {
implicitHeight: 50
color:"green"
}
background: Rectangle{
color:"red"
}
onPositionChanged: {
//How to move the chart
}
}
}
我还发现ChartView 有等功能,但我不知道如何将这些功能与滚动条集成
ScrollDown
。ScrollRight
有没有其他方法可以在不使用 QML 的情况下绘制数据
QT Charts
?
请建议我使用 QT 5.9.1。