PDA

View Full Version : retrieving data from a QWT plot



mobucl
26th May 2011, 12:40
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

FelixB
26th May 2011, 13:00
Hi Matt,


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