Exception calling QChart::removeAllSeries
-
Class has a QLineSeries, and QChart
QLineSeries scoreSeries; QChart scoreChart;and a chart view that was set using:
chartView->setChart(&scoreChart);If I have a datapoint I want to add I call:
scoreSeries.append(x, fScore); scoreChart.removeAllSeries(); scoreChart.addSeries(&scoreSeries);
thinking that would refresh display of the ChartView.
The first time I called that it worked, but when I added the second point to the series I get this:

- I don't think that should happen!
- Am I doing this all wrong?
- If I have got it wrong what should I do?
Thanks
David -
Class has a QLineSeries, and QChart
QLineSeries scoreSeries; QChart scoreChart;and a chart view that was set using:
chartView->setChart(&scoreChart);If I have a datapoint I want to add I call:
scoreSeries.append(x, fScore); scoreChart.removeAllSeries(); scoreChart.addSeries(&scoreSeries);
thinking that would refresh display of the ChartView.
The first time I called that it worked, but when I added the second point to the series I get this:

- I don't think that should happen!
- Am I doing this all wrong?
- If I have got it wrong what should I do?
Thanks
David@Perdrix said in Exception calling QChart::removeAllSeries:
scoreChart.addSeries(&scoreSeries);My guess would be that
QChartexpects allQLineSeries(any series) added to it to be on the heap, not stack, and doesdeletes on them. Try that and everything is then OK? -
P Perdrix has marked this topic as solved on
-
@Perdrix said in Exception calling QChart::removeAllSeries:
scoreChart.addSeries(&scoreSeries);My guess would be that
QChartexpects allQLineSeries(any series) added to it to be on the heap, not stack, and doesdeletes on them. Try that and everything is then OK?@JonB Yes that was part of it plus RemoveAll also deleted the line series, so now I have:
if (nullptr != scoreSeries) scoreChart.removeSeries(scoreSeries); else scoreSeries = new QLineSeries(this); scoreSeries->append(x, fScore); scoreChart.addSeries(scoreSeries); scoreChart.createDefaultAxes();