Qt 如何使用模型更新图表?
我使用的是example而不是customtablemodel.cpp。我将其名称更改为ScopeDataModel,并在qml代码中使用它。但是当我运行这段代码时,它并没有更新图表上的数据Qt 如何使用模型更新图表?,qt,widget,qml,qtableview,qtcharts,Qt,Widget,Qml,Qtableview,Qtcharts,我使用的是example而不是customtablemodel.cpp。我将其名称更改为ScopeDataModel,并在qml代码中使用它。但是当我运行这段代码时,它并没有更新图表上的数据 ScopeDataModel{ id:scopeModel } ChartView { id: chartView title: " Scope " anchors.fill: parent legend.visible: false antialiasi
ScopeDataModel{
id:scopeModel
}
ChartView
{
id: chartView
title: " Scope "
anchors.fill: parent
legend.visible: false
antialiasing: true
backgroundColor: "white"
plotAreaColor: "white"
titleColor: "white"
ValueAxis {
id: axisX
titleText:componentData.readXAxisName
min: componentData.changeXMin
max: componentData.changeXMax
tickCount: 1
}
ValueAxis {
id: axisY
titleText:componentData.readYAxisName
min: componentData.changeYMin
max: componentData.changeYMax
tickCount: 1
}
LineSeries {
id: lineSeries
name: "Data Output"
axisX: axisX
axisY: axisY
useOpenGL: true
VXYModelMapper{
model:scopeModel
xColumn:0
yColumn:1
series:lineSeries
}
}
}
根据您提供的代码,您不会为模型设置数据,也不会对其进行任何更改。您好,感谢您的回复。你能帮我设置相同的数据吗?如果你在Qt中定义了模型,你可以使用:QQmlContext*context=view.engine()->rootContext();context->setContextProperty(“\u myModel,&model”);