Hello. I'm trying to redraw chart with a new data and delete previous chart.
So here is my code.
QChart *oldSignalData = signalView->chart();
signalData = new QChart();
signalData->legend()->hide();
signalData->addSeries(signalSamples);
signalData->createDefaultAxes();
signalData->setTitle(comboTests->currentText());
signalView->setChart(signalData);
if(NULL != oldSignalData){
delete oldSignalData;
}
QChart *oldSignalData = signalView->chart();
signalData = new QChart();
signalData->legend()->hide();
signalData->addSeries(signalSamples);
signalData->createDefaultAxes();
signalData->setTitle(comboTests->currentText());
signalView->setChart(signalData);
if(NULL != oldSignalData){
delete oldSignalData;
}
To copy to clipboard, switch view to plain text mode
But when i putting a new QChart on a same QChartView - it fails with a message "Can not find axis on the chart."
This code works fine if i comment "delete oldSignalData;" string, but it causes memory leaks. What is the correct
way to delete previous chart and do not crush QChartView? Thanks.
Qt version - 5.8.0.
Bookmarks