Results 1 to 3 of 3

Thread: QwtPlotCurve only display the last curve?

  1. #1
    Join Date
    Jan 2014
    Posts
    16
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default QwtPlotCurve only display the last curve?

    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.

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,250
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlotCurve only display the last curve?

    You need to create and attach 2 curves - your code assigns 2 different sets of points to the same curve.

    Uwe

  3. #3
    Join Date
    Jan 2014
    Posts
    16
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlotCurve only display the last curve?

    Uwe ,thank you very much ,now it works!
    Quote Originally Posted by Uwe View Post
    You need to create and attach 2 curves - your code assigns 2 different sets of points to the same curve.

    Uwe

Similar Threads

  1. Replies: 3
    Last Post: 16th December 2014, 06:43
  2. Replies: 11
    Last Post: 5th February 2013, 02:10
  3. Replies: 1
    Last Post: 27th April 2011, 15:13
  4. Replies: 4
    Last Post: 29th April 2010, 07:11
  5. Replies: 1
    Last Post: 9th December 2009, 18:14

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.