mein Programm stürzt leider ohne Fehlermeldung ab wenn ich myplot->replot(); ausführe
Der Debugger sagt Segmentation Fault...
Woran liegts? Danke
Code: Alles auswählen
myplot = new QwtPlot(this);
myplot->move(QPoint(400,50));
myplot->setTitle("Messkurve");
myplot->setCanvasBackground(Qt::white);
myplot->setFixedSize(400,345);
mycurve = new QwtPlotCurve();
mycurve->setTitle("Line");
mycurve->setPen(QPen(Qt::black));
mycurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 )
<< QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 )
<< QPointF( 4.0, 7.9 ) << QPointF( 5.0, 7.1 );
mycurve->setSamples( points );
mycurve->attach(myplot);
myplot->show();Code: Alles auswählen
void MainWindow::slot_set_values(double ptm_temp, double ptm_hv, double heat_temp, double nomtemp, double current, double voltage)
{
using namespace GLOBAL;
ui->pmtValueLabel->setText(QString::number(ptm_temp));
ui->hvValueLabel->setText(QString::number(ptm_hv));
ui->heatValueLabel->setText(QString::number(heat_temp));
ui->nomValueLabel->setText(QString::number(nomtemp));
ui->currenValueLabel->setText(QString::number(current));
ui->vValueLabel->setText(QString::number(voltage));
points << QPointF(i++, ptm_hv);
QList<QPointF> plist = points.toList();
if (!plist.isEmpty())
{
for(int i = 0; i < plist.count(); i++)
{
qDebug() << "listed" << plist[i].x() << plist[i].y();
}
}
myplot->replot(); // Absturz :-(
}Code: Alles auswählen
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDebug>
#include <QThread>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
QwtPlot *myplot;
QwtPlotCurve *mycurve;
private slots:
void on_startButton_clicked();
void on_stopButton_clicked();
public slots:
void slot_set_values(double ptm_temp, double ptm_hv, double heat_temp, double nomtemp, double current, double voltage);
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
Code: Alles auswählen
#include "mainwindow.h"
#include "ui_mainwindow.h"
namespace GLOBAL
{
QPolygonF points;
int valuecounter = 0;
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
using namespace GLOBAL;
ui->setupUi(this);
myplot = new QwtPlot(this);
myplot->move(QPoint(400,50));
myplot->setTitle("Messkurve");
myplot->setCanvasBackground(Qt::white);
myplot->setFixedSize(400,345);
mycurve = new QwtPlotCurve();
mycurve->setTitle("Line");
mycurve->setPen(QPen(Qt::black));
mycurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
points << QPointF( 0.0, 4.4 ) << QPointF( 1.0, 3.0 )
<< QPointF( 2.0, 4.5 ) << QPointF( 3.0, 6.8 )
<< QPointF( 4.0, 70.9 ) << QPointF( 5.0, 7001 );
mycurve->setSamples( points );
mycurve->attach(myplot);
myplot->show();
//myplot->replot(); <-- das funktioniert!
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::slot_set_values(double ptm_temp, double ptm_hv, double heat_temp, double nomtemp, double current, double voltage)
{
using namespace GLOBAL;
ui->pmtValueLabel->setText(QString::number(ptm_temp));
ui->hvValueLabel->setText(QString::number(ptm_hv));
ui->heatValueLabel->setText(QString::number(heat_temp));
ui->nomValueLabel->setText(QString::number(nomtemp));
ui->currenValueLabel->setText(QString::number(current));
ui->vValueLabel->setText(QString::number(voltage));
points << QPointF(valuecounter++, ptm_hv);
QList<QPointF> plist = points.toList();
if (!plist.isEmpty())
{
for(int i = 0; i < plist.count(); i++)
{
qDebug() << "points" << plist[i].x() << plist[i].y();
}
}
myplot->replot(); <-- hier stürzt er ab!
//qDebug() <<"set_values SLOT " <<ptm_temp<<" "<<ptm_hv<<" "<<heat_temp<<" "<<nomtemp<<" "<<current<<" "<<voltage;
}
Code: Alles auswählen
mycurve->setSamples( points ); //hinzu gefügt
myplot->replot();