Results 1 to 2 of 2

Thread: retrieving data from a QWT plot

  1. #1
    Join Date
    Dec 2010
    Posts
    31
    Thanks
    9
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default retrieving data from a QWT plot

    Hi, sorry if this may seem really simple but ive been looking around for ages to work out how to do this! So first i create a plot on my graph containing some X and Y values:

    QwtPlotCurve *curvedata = new QwtPlotCurve("data");
    curvedata->setSamples(x,y);
    curvedata->setPen(QPen(Qt::black));
    curvedata->attach(ui->plot);
    ui->plot->replot();

    Then i know i can plot a second set of data on top in a seperate part of the code using:

    QwtPlotCurve *STDPlot = new QwtPlotCurve("STD");
    STDPlot->setSamples(x,y);
    STDPlot->setPen(QPen(Qt::black, 2));
    STDPlot->attach(ui->plot);
    STDPlot->setStyle(QwtPlotCurve::Sticks);
    ui->plot->replot();

    So now i have two sets of data on the same graph. Ok but now what if i want to retrieve my values from the first plot to check (for example) the maximum and then normalize the second set of values to this.

    I found that

    QwtPlotItemList test;
    test = ui->plot->itemList();

    allows me to get the information which is on the graph but i cannot figure out how i go from this to obtaining the XY data checking it and then updating it in the plot.

    Sorry if this seems simple!

    Indecently does anyone know a good QWT tutorial on the web with simple explanations on how to do these kind of basic things?

    Thanks

    Matt

  2. #2
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: retrieving data from a QWT plot

    Hi Matt,

    Quote Originally Posted by mobucl View Post
    allows me to get the information which is on the graph but i cannot figure out how i go from this to obtaining the XY data checking it and then updating it in the plot.
    you get a list containing pointers to QwtPlotItem. some of them (in your case probably all) are of type QwtPlotCurve - these are your curves. So, loop over the list. try to cast each entry into a pointer to QwtPlotCurve. if casting was successfull, you have a pointer on one of your curves. you can distinguish between the curves by comparing the name. now, you can do something with this curve.

    maybe it is a better idea to keep a pointer on your curves as a member.

    feel free to ask for specific things you don't understand.
    Felix

Similar Threads

  1. SQL Server data retrieving speed problem
    By Aleksandar in forum Qt Programming
    Replies: 4
    Last Post: 9th December 2010, 14:52
  2. Debugger problem retrieving data for watch view hangs
    By frenk_castle in forum Installation and Deployment
    Replies: 0
    Last Post: 6th May 2010, 00:09
  3. 2D array data plot!
    By kahramonj in forum Qwt
    Replies: 3
    Last Post: 21st March 2009, 12:48
  4. plot only subset of the data
    By pospiech in forum Qwt
    Replies: 3
    Last Post: 14th April 2008, 22:19

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.