PDA

View Full Version : qwtplot run time error



hamid ghous
13th August 2009, 09:40
Hi,



I am developing an application with Qwt and trying to get a scatter graph. I did the same thing by using Qframe class but I want to add few more functionality like zooming and printing.
So can you please help me this code just tell me where I am doing wrong.So far code is compiling fine with no errors but when I run the generated exe file it says"The appliction has requested the runtime to terminate in unsual way..." which I have seen is a kind of programming error.



#include <qapplication.h>
#include <qframe.h>
//#include <qwt_scale_map.h>
#include <qwt_plot_curve.h>
#include <qwt_symbol.h>
#include <qcolor.h>
#include <qpainter.h>
#include <math.h>
#include <qwt_plot.h>

//
// Array Sizes
//
const int Size = 26;


double xval[Size];
double yval[Size];
QwtScaleMap xMap;
QwtScaleMap yMap;
//QwtPlot *myPlot = new QwtPlot(QWidget parent = NULL);



QwtPlotCurve *curve1 = new QwtPlotCurve();

class MainWin : public QwtPlot
{

public:
MainWin( );

};
MainWin::MainWin()
{
int i;

QwtPlot *myPlot;
myPlot= new QwtPlot();

//xMap.setScaleInterval(-0.5, 10.5);
// yMap.setScaleInterval(-1.1, 1.1);

//
// Calculate values
//
for(i=0; i<Size;i++)
{ xval[i] = double(i) * 10.0 / double(Size - 1);
yval[i] = sin(xval[i]) * cos(2.0 * xval[i]);
}


//myplot->setCurveData(c1, xval, yval, 100);
curve1->setRawData(xval,yval,Size);


curve1->attach(myPlot);

//curve1->attach(&plot);

myPlot->replot();


}

int main (int argc, char **argv)
{
QApplication a(argc, argv);

MainWin w;


// w.resize(300,500);
w.show();

return a.exec();
}

I would really appreciate your help.

Cheers,

emrares
13th August 2009, 10:55
class MainWin : public QwtPlot

this means you don't have to create a QwtPlot *myPlot; for displaying the plot

you shoud only do curve1->attach(this);

and than replot

I don't know if this is the problem but you should try

hamid ghous
13th August 2009, 14:33
Thanks Eme,

I did the changes but error is still the same... Also I am trying to find the exact error by using DrMingw but I dont know how to read the resulted file from DrMingw.

Any other suggestion.

Cheers,