Hi QWT Forumers!
I'd like to draw 2d array data and it is my first experience with QWT, everything is OK, but the following code is drawing only ONE(last) curve. Dear fellowship, please help !
Plot::Plot()
{
setTitle("A Simple QwtPlot Demonstration");
// Set axis titles
setAxisTitle(xBottom, "x -->");
setAxisTitle(yLeft, "y -->");
// Insert new curves
#if QT_VERSION >= 0x040000
#endif
cSin
->setPen
(QPen(Qt
::red));
cSin->attach(this);
const int nPoints = 100;
double x[2][nPoints], y[2][nPoints];
for(int j=0; j<2; j++)
{
for(int i=0; i<nPoints; i++)
{
x[j][i] = -3.14 + i*(j+2)*3.14/(nPoints-1);
y[j][i] = sin((j+1)*x[j][i]);
}
}
// Create 2d array data
for(int j=0; j<2; j++)
cSin->setData(x[j],y[j],nPoints);
}
Plot::Plot()
{
setTitle("A Simple QwtPlot Demonstration");
insertLegend(new QwtLegend(), QwtPlot::RightLegend);
// Set axis titles
setAxisTitle(xBottom, "x -->");
setAxisTitle(yLeft, "y -->");
// Insert new curves
QwtPlotCurve *cSin = new QwtPlotCurve("y = sin(x)");
#if QT_VERSION >= 0x040000
cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
#endif
cSin->setPen(QPen(Qt::red));
cSin->attach(this);
const int nPoints = 100;
double x[2][nPoints], y[2][nPoints];
for(int j=0; j<2; j++)
{
for(int i=0; i<nPoints; i++)
{
x[j][i] = -3.14 + i*(j+2)*3.14/(nPoints-1);
y[j][i] = sin((j+1)*x[j][i]);
}
}
// Create 2d array data
for(int j=0; j<2; j++)
cSin->setData(x[j],y[j],nPoints);
}
To copy to clipboard, switch view to plain text mode
Bookmarks