Filling ChartView with populated serie from c++

203 Views Asked by At

I need to fill QML ChartView with LineSeries. I am doing it by invoking method from c++:

    QMetaObject::invokeMethod(m_chartview, "createSeries", Qt::DirectConnection,
                          Q_RETURN_ARG(QAbstractSeries *, serie),
                          Q_ARG(int, type),
                          Q_ARG(QString, ("Chart "+QString::number(index+1))),
                          Q_ARG(QAbstractAxis *, axis_x),
                          Q_ARG(QAbstractAxis *, axis_y));

and then appending points to created serie:

if(QLineSeries *line_serie = qobject_cast<QLineSeries *>(serie)){
    static std::default_random_engine e;
    static std::uniform_real_distribution<> dis(0, 3);
    for(int i=0; i < 10; i++){
        line_serie->append(i, dis(e));
    }
}

It's working fine with small number of data, but extremely slow with large number of data. The problem is that each 'append' triggers redrawing. So my question is: is there any way to add serie to ChartView only after it has been populated with points?

0

There are 0 best solutions below