QCustomPlot Discussion and Comments

How to Delete Plots QCPFinancialReturn to overview

I am going over this Tutorial financial demo
OHLC plot

QCPFinancial *ohlc = new QCPFinancial(customPlot->xAxis, customPlot->yAxis);

creates the structure.

in subsequent calls to this function more graphs are added to the plot.

However I would like to check if there is any such plot and delete it before plotting a new graph

Any suggestions how I would do that

ui->customPlot->clearGraphs();
ui->customPlot->replot();
Does not clear existing plots

clearGraphs only clears things that are QCPGraph. you would need to call clearPlottables for QCPFinancial.

Alternatively, you can call plottable(index) and check if it exists, then you can delete it with removePlottable(index).

You can also keep a pointer to all of your QCPFinancial and call removePlottable(plottable*) with that pointer to remove and delete it.