PDA

View Full Version : what is the Fix to the bug in plooting simple graph using qwt int qt?



anamr
29th October 2010, 18:11
HI i am not able to fix the error .
It gives Errror during compiling as

5412

This is the code i wrote
--------------------------------------------------------------------------------


#include<qwt.h>
#include<math.h>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include<QApplication>
int main(int argc, char **argv )
{


QwtPlot *myPlot = new QwtPlot();

// add curves
QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");
QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2");

// copy the data into the curves
const int points = 500;
double x[ points ];
double sn[ points ];
double sg[ points ];

for( int i=0; i<points; i++ )
{
x[i] = (3.0*3.14/double(points))*double(i);

sn[i] = 2.0*sin( x[i] );
sg[i] = (sn[i]>0)?1:((sn[i]<0)?-1:0);
}
curve1->setData(x, sn, points );
curve2->setData( x, sg, points);

curve1->attach(myPlot);
curve2->attach(myPlot);

// finally, refresh the plot
myPlot->replot();
}

Uwe
3rd December 2010, 09:30
Don't try to compile code that was written for Qwt 5.x against Qwt 6.x.

Uwe