我在qml中声明了ChartView
:
ChartView {
id: testGraph
objectName: "testGraph"
}
我把它连接到c ++:
QObject *loader = engine.rootObjects().at(0)->findChild<QObject*>("loader");
QObject *item = qvariant_cast<QObject*>(QQmlProperty::read(loader, "item"));
QObject *chart = item->findChild<QObject *>("testGraph");
我在c ++中有QLineSeries
:
QLineSeries *series = new QLineSeries();
series->append(0, 6);
series->append(2, 4);
series->append(3, 8);
series->append(7, 4);
series->append(10, 5);
*series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);
现在我如何将chart
连接到QLineSeries
。我尝试将chart
投射到QChartView
,但它没有addSeries
方法QChart
。