QCustomPlot Discussion and Comments

how to reset a QCustomPlot control to its initial state to reuse it?Return to overview

you give us plot-examples.pro project.
I want to learn from it.
I adapted it to show all the examples in one run.

I added a spinbox to change demo:

  connect(ui->spinBox, SIGNAL(valueChanged(int)), this, SLOT(changeDemo(int)));

void MainWindow::changeDemo(int i)

But when I change from demo 17 to demo 16, it crashes because addGraph return nullptr. The root cause is yAxis is deleted by demo 17.
I wonder if there is a method to reset QCustomPlot control to its initial state?

Can anyone support me?

Have a look at the QMainWindow::allScreenShots method in the plot example project. There I do just what you want, by deleting the old QCustomPlot and creating a fresh one.

Thanks, DerManu.
This is the last method we can rely on.
Hope QCustomPlot developers can take this demand into consideration, add a reset() method.