0

I have a QCustomPlot widget in my ui as follows:

ui->plot_widget

also I have another QCustomPlot object in my cpp file as follows:

QCustomPlot *plot=new QCustomPlot();

I want to add plot data into ui->plot_widget data. If I use ui->plot_widget=plot the widget parent of ui->plot_widget will be destroyed and my ui does not update ui->plot_widget.

How can I add plot data into ui->plot_widget data?

  • Why do you want to add a QCustomPlot to another QCustomPlot?, Use: `ui->plot_widget->addGraph()` after: `ui->graph(0)->setData(your_x_data, your_y_data)`, read this: http://www.qcustomplot.com/index.php/tutorials/basicplotting – eyllanesc Jan 19 '18 at 16:56
  • @eyllanesc thanks, I have a function that returns a `QCustomPlot` object and I want to show that plot in my ui. I check it and reply –  Jan 19 '18 at 17:00
  • QCustomPlot is a widget that handles several plots. – eyllanesc Jan 19 '18 at 17:00
  • You have a bad design then, think and redesign your code. – eyllanesc Jan 19 '18 at 17:01
  • @eyllanesc thanks, I have a problem in using `QCustomPlot` in a new thread, so to solving I use a trick and explained here. Can you see this question [https://stackoverflow.com/questions/48337058/qt-qcustomplot-in-a-new-thread] –  Jan 19 '18 at 17:08
  • @eyllanesc because my plot takes a long time and I want to show in status bar a loading gif and also I want to have a responsible ui –  Jan 19 '18 at 17:14
  • I have a class that generates the plot and computing the data of the plot takes too long –  Jan 19 '18 at 17:18

0 Answers0