OS: Ubuntu 18.02
GCC version 7.4.0
QMake Version 3.1
Qt Version 5.9.5
QWT Version 6.1.4

Hello Everyone!

I created a qwtplot array, and set a point on origin.

When I delete the qwtplot array before close qt windows, the Qt program is crashed.

The Code is show in the following

mainwindows.h
Qt Code:
  1. #include <QMainWindow>
  2. #include <qwt_plot.h>
  3. #include <qwt_plot_curve.h>
  4. #include <qwt_plot_grid.h>
  5. #include <qwt_plot_canvas.h>
  6. #include <qwt_plot_curve.h>
  7. #include <qwt_plot_grid.h>
  8. #include <qwt_symbol.h>
  9. #include <QPolygonF>
  10. namespace Ui {
  11. class MainWindow;
  12. }
  13. class MainWindow : public QMainWindow
  14. {
  15. Q_OBJECT
  16. public:
  17. explicit MainWindow(QWidget *parent = 0);
  18. ~MainWindow();
  19. private:
  20. Ui::MainWindow *ui;
  21. QwtPlot *qwtpt;
  22. QPolygonF *polygon;
  23. QwtPlotCurve *curve;
  24. QwtPlotGrid *grid;
  25. QwtSymbol *symbol;
  26. };
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp
Qt Code:
  1. MainWindow::MainWindow(QWidget *parent) :
  2. QMainWindow(parent),
  3. ui(new Ui::MainWindow)
  4. {
  5. ui->setupUi(this);
  6. int numpoints = 10;
  7. qwtpt = new QwtPlot[numpoints];
  8. polygon = new QPolygonF[numpoints];
  9. curve = new QwtPlotCurve[numpoints];
  10. grid = new QwtPlotGrid[numpoints];
  11. symbol = new QwtSymbol[numpoints];
  12. QString style = "color: white; ";
  13. QPolygonF initialpoint;
  14. initialpoint << QPointF(0.0f, 0.0f);
  15. int k;
  16. for(k = 0; k < numpoints; ++k){
  17. //plot
  18. qwtpt[k].setParent(ui->scrollArea);
  19. qwtpt[k].setGeometry(10, 20 + 181 * k, 760, 161);
  20. qwtpt[k].setAxisTitle(QwtPlot::xBottom, "points");
  21. qwtpt[k].setAxisTitle(QwtPlot::yLeft, "efficience %");
  22. qwtpt[k].setAxisScale(QwtPlot::xBottom, 0.0, 132);
  23. qwtpt[k].setAxisScale(QwtPlot::yLeft, 0.0, 100);
  24. qwtpt[k].setStyleSheet(style);
  25. //symbol
  26. symbol[k].setPen(QPen(Qt::red, 2));
  27. symbol[k].setStyle(QwtSymbol::Ellipse);
  28. symbol[k].setBrush(QBrush(Qt::yellow));
  29. symbol[k].setSize(QSize(8,8));
  30. //curve
  31. curve[k].setPen(Qt::blue, 4);
  32. curve[k].setRenderHint(QwtPlotItem::RenderAntialiased, true);
  33. curve[k].setSymbol(&symbol[k]);
  34. curve[k].attach(&qwtpt[k]);
  35. curve[k].setSamples(initialpoint);
  36. //grid
  37. grid[k].attach(&qwtpt[k]);
  38. }
  39. }
  40. MainWindow::~MainWindow()
  41. {
  42. delete [] qwtpt; // crash on this line
  43. delete [] polygon;
  44. delete [] curve;
  45. delete [] grid;
  46. delete [] symbol;
  47. delete ui;
  48. }
To copy to clipboard, switch view to plain text mode 

if I do not to delete the qwtpt array, the Qt debug show the crash on function ~MainWindow()

if I exchange position between qwtpt and curve, the crash is happened on “delete [] curve”
Qt Code:
  1. delete [] curve; // crash on this line
  2. delete [] polygon;
  3. delete [] qwtpt;
  4. delete [] grid;
  5. delete [] symbol;
  6. delete ui;
To copy to clipboard, switch view to plain text mode 

Maybe I must to do something before delete the qwtplot array.

Is anyone have idea, or some suggestion for this issues?

Thanks in advance.