0

I want to use function which is changing QLineSeries values. And when it called first time everything is good. But when it called second time looping is working too long.

How to do this correctly?

    //...
    QChart *chart = new QChart();
    chart->legend()->hide();
    chart->addSeries(series);
    chart->createDefaultAxes();
    ui_.chart->setChart(chart);
    ui_.chart->setRenderHint(QPainter::HighQualityAntialiasing);
    //...
}

void Wnd::setSeries(QLineSeries *lineSeries, const std::vector<double> &arr)
{
    lineSeries->clear();

    for (int i = 0; i < arr.size(); ++i) {
        lineSeries->append(i, arr[i]);
    }
}
Ufx
  • 2,595
  • 12
  • 44
  • 83
  • How much data are you saving? – eyllanesc Jan 21 '18 at 21:52
  • More than 100 000. – Ufx Jan 21 '18 at 21:52
  • enable the use of [opengl](https://doc.qt.io/qt-5.10/qtcharts-openglseries-example.html), `lineSeries->setUseOpenGL(true);`, also the problem is the data load, I would recommend using a QTimer to load data but that is little by little, for example a thousand data per call. They are a lot of data for a moment. – eyllanesc Jan 21 '18 at 21:55
  • after `lineSeries->setUseOpenGL(true);` something from my desktop is painting in the chart. And it still working too long when it is called second time. – Ufx Jan 21 '18 at 21:59

0 Answers0