QCustomPlot Discussion and Comments

How to determine if a data has been set to any graph?Return to overview

In an application where I plot multiple lines in a QCustomPlot, I need to add newData to the plot dynamically, something like this:

//QVector<double> newData; at somewhere else
QCPGraph *graph = ui->customPlot->addGraph();
graph->setData(x, newData);

Is there an easy way to prevent creating new graph for newData if it has been added to a graph before? In QChart, addSeries will reject QSplineSeries etc if it has been added before, I wonder if QCustomPlot can do something similar? Thanks.

if the new graph has been added, it has been added the graph queue last. it will not judge whether it is already there. so you must remember it outside, such as QMap<QString, QCPGraph *>. maybe Modifying the source code.