How to get the index of a certain Graph/Curve by name ?
if more than 1 graph/ curve exists and all have different names.
How to get the index of a certain Graph/Curve by name ?
if more than 1 graph/ curve exists and all have different names.
Just loop through by index:
int foundIndex = -1; for (int i=0; i<customPlot->graphCount(); ++i) { if (customPlot->graph(i)->name() == theName) { foundIndex = i; break; } }
foundIndex
will then either contain the index of the graph you're looking for or -1 if there's no graph with that name. If you want both curves and graphs (and other plottables), exchange graphCount
/graph
with plottableCount
/plottable
.
thank you ! :)