J
Also ich habe jetzt noch den Konstruktor der Basisklasse aufgerufen und noch an anderer Stelle versucht den Code zu korrigieren...leider bleibt das Problem das selbe.
@Q:
Könntest du mir genauer erklären, wie es möglich is diese Informationen vom Debugger zu bekommen?
Denn der Build verläuft ja erfolgreich und der Fehler tritt erst beim Betätigen des Buttons auf...
Hier mal noch der neue Code:
Plot.h
class Graph : public QwtPlot
{
public:
Graph(QWidget* parent);
QwtPlot *myPlot;
};
#endif
Plot.cpp
Graph::Graph(QWidget *parent) : QwtPlot (parent)
{
myPlot= new QwtPlot(parent);
myPlot->setAutoFillBackground( true );
myPlot->setPalette( QPalette( QColor( 165, 193, 228 ) ) );
myPlot->setTitle("Plot 1.0");
myPlot->insertLegend(new QwtLegend(), QwtPlot::RightLegend);
// axes
myPlot->setAxisTitle(xBottom, "x -->" );
myPlot->setAxisScale(xBottom, 0, 10);
myPlot->setAxisTitle(yLeft, "y -->");
myPlot->setAxisScale(yLeft, 0, 10);
myPlot->setAutoReplot(true);
}
Plotm.h
#define PLOTM_H
#include "ui_Plot10.h"
#include <qdialog.h>
class Plotm : public QMainWindow, public Ui::MainWindow
{
Q_OBJECT
public:
Plotm (QMainWindow *parent = 0);
~ Plotm ();
int avalue;
int bvalue;
int xmax;
int xmin;
int ymax;
int ymin;
double xval[100];
double yval[100];
private slots:
void draw();
};
#endif //PLOTM_H
Plotm.cpp
#include "Plotm.h"
#include "Plot.h"
Plotm::Plotm(QMainWindow *parent) : QMainWindow(parent)
{
setupUi(this);
xmi-> setText("0");
ymi-> setText("0");
connect(plotb, SIGNAL(clicked()), this, SLOT(draw()));
}
Plotm::~Plotm()
{}
void Plotm::draw()
{
Graph* plot ;
QDialog* nw;
QHBoxLayout *layout;
nw = new QDialog(this, Qt::Window);
plot = new Graph(nw);
layout = new QHBoxLayout(nw);
layout->setContentsMargins( 0, 0, 0, 0 );
layout->addWidget(plot);
int ava;
int bva;
int xmax;
int xmin;
int ymax;
int ymin;
ava = aval->text().toDouble();
bva = bval->text().toDouble();
xmax = xma->text().toDouble();
xmin = xmi->text().toDouble();
ymax = yma->text().toDouble();
ymin = ymi->text().toDouble();
double xval[100];
double yval[100];
for(int i=0; i<100;i++)
{
xval[i] = double(i) * ((xmax - xmin) / 100);
yval[i] = ava * xval[i] + bva;
}
QwtPlotCurve * d_curves = new QwtPlotCurve("y = a*x+b");
d_curves->setRenderHint(QwtPlotItem::RenderAntialiased);
d_curves->setLegendAttribute(QwtPlotCurve::LegendShowLine, true);
d_curves->setPen(QPen(Qt::green));
d_curves->setRawSamples(xval, yval, 100);
d_curves->attach(plot);
nw->resize(800,600);
plot->show();
nw->show();
}