从c ++设置QLineSeries

时间:2017-10-17 10:23:46

标签: c++ qt qml

我在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

0 个答案:

没有答案