Hey guys,
I am really desperate. Therefore I reconstructed my problem in a plain new project.
This is the constructor of the 'mainwindow' class, which is called by main:
#include <QObject>
#include <QMainWindow>
#include <QtGui>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_data.h>
#include "ui_GUI_mainwindow.h"
#include "m_mainwindow.h"
#include "m_plot.h"
M_MainWindow
::M_MainWindow(QWidget *parent
){
setupUi(this);
double x[] = {1, 2, 3, 4, 5};
const double* x_ptr = x;
const double* y_ptr = x;
curve1->setData ( qwtArray );
qwtPlot->replot();
// M_Plot qPlot; // <- HERE IS THE PROBLEM
}
#include <QObject>
#include <QMainWindow>
#include <QtGui>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_data.h>
#include "ui_GUI_mainwindow.h"
#include "m_mainwindow.h"
#include "m_plot.h"
M_MainWindow::M_MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setupUi(this);
double x[] = {1, 2, 3, 4, 5};
const double* x_ptr = x;
const double* y_ptr = x;
QwtArrayData qwtArray ( x_ptr, y_ptr, 5 );
QwtPlotCurve *curve1 = new QwtPlotCurve ( "Curve 1" );
curve1->setData ( qwtArray );
curve1->attach( qwtPlot );
qwtPlot->replot();
// M_Plot qPlot; // <- HERE IS THE PROBLEM
}
To copy to clipboard, switch view to plain text mode
The line is plotted in the qwt widget as expected. If I include:
'M_Plot qPlot;' the program crashes and I receive the 'segmentation fault' error. Compiling the program is not a problem.
This is the constructor for the M_Plot class:
#include <QObject>
#include <QMainWindow>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_data.h>
#include "ui_GUI_mainwindow.h"
#include "m_plot.h"
M_Plot::M_Plot()
{
double x[] = {2, 4, 6, 8, 10};
const double* x_ptr = x;
const double* y_ptr = x;
curve1->setData ( qwtArray );
qwtPlot->replot();
}
#include <QObject>
#include <QMainWindow>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_data.h>
#include "ui_GUI_mainwindow.h"
#include "m_plot.h"
M_Plot::M_Plot()
{
double x[] = {2, 4, 6, 8, 10};
const double* x_ptr = x;
const double* y_ptr = x;
QwtArrayData qwtArray ( x_ptr, y_ptr, 5 );
QwtPlotCurve *curve1 = new QwtPlotCurve ( "Curve 1" );
curve1->setData ( qwtArray );
curve1->attach( qwtPlot );
qwtPlot->replot();
}
To copy to clipboard, switch view to plain text mode
I really don't know what I am doing wrong. Maybe I am already blinded and can't find an obvious mistake.
I posted a stack trace in a previous post yesterday.
System specs:
openSUSE 11.1
qwt 5.2.0 -> from the repositories
Qt 4.4.3
gcc-c++ 4.3
KDevelop 3.5.3
greetz, kai
Edit: I just compiled qwt 5.2.0 from Sourceforge and used it in the program, but also didn't help. Damn it
Bookmarks