hello all,
i want to plot multiple curves use QVector<> ,however i only get the last curve in QVector ,my code is as follow:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->qwtPlot->setCanvasBackground( Qt::white );
ui->qwtPlot->setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );
QVector<QwtPlotCurve *> curveVector;
QwtPlotCurve *curve = new QwtPlotCurve();
curve->setPen( Qt::blue );
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
QPolygonF points;
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 );
curve->setSamples( points );
curveVector.push_back(curve);
//curve->attach(ui->qwtPlot);
points.clear();
curve->setPen( Qt::red ),
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true );
//QPolygonF points;
points << QPointF( 0.0, 3.4 ) << QPointF( 1.0, 2.0 )
<< QPointF( 2.0, 3.5 ) << QPointF( 3.0, 5.8 )
<< QPointF( 4.0, 6.9 ) << QPointF( 5.0, 6.1 );
curve->setSamples( points );
curveVector.push_back(curve);
for (int i=0;i<curveVector.size();i++)
{
curveVector.value(i)->attach(ui->qwtPlot);
}
ui->qwtPlot->resize( 600, 400 );
}
how can i solve this problem?
Micky Jhon.
Bookmarks