что-то не так с моим кодом, когда я запускаю свою программу (пример QWT), я получаю эту ошибку (программа неожиданно завершилась). Почему я получаю это сообщение об ошибке и как его исправить?
Спасибо
вот мой код:
main.cpp
#include "mainwindow.h"
#include <QtGui>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
w.resize(400, 450);
return a.exec();
}
mainwindow.cpp
#include "mainwindow.h"
MainWindow:: MainWindow(QWidget *parent) :
QMainWindow(parent)
{
CreateGui();
}
MainWindow::~MainWindow()
{
}
void MainWindow::CreateGui()
{
QwtPlot *myPlot = new QwtPlot(centralWidget());
QwtPlotCurve *courbe = new QwtPlotCurve("Courbe 1");
QLineEdit *test = new QLineEdit;
QVector<double> x(5);
QVector<double> y(5);
// On entre des valeurs
for(int i=0;i<5;i++)
{
x.append((double)i);
y.append((double)(5-i));
}
courbe->setSamples(x.data(),y.data(),x.size());
myPlot->replot();
courbe->attach(myPlot);
QGridLayout *layout = new QGridLayout;
layout->addWidget(myPlot, 0, 1);
layout->addWidget(test,1,0);
centralWidget()->setLayout(layout);
}
and mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QObject>
#include <QMainWindow>
#include<QLineEdit>
#include<QGridLayout>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
class MainWindow: public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent=0);
~MainWindow();
private:
private slots:
void CreateGui();
};
#endif // MAINWINDOW_H