[SOLVED]QWT plot doesn’t like my array
-
wrote on 28 Nov 2011, 12:18 last edited by
I try to use the QWt plot graph and I tried a little example.
But it crashes in the@curve1->setData(x,y1,100);@
//Error msg
error: no matching function for call to ‘QwtPlotCurve::setData(double [100], double [100], int)’My code
@ ui->qwtPlot->setTitle("TWO CURVES");
ui->qwtPlot->setParent(ui->tab_4);double x[100], y1[100]; for (int i = 0; i < 100; i++) { x[i] = i; y1[i] = 10-0.1*i*i; }
// add curves
QwtPlotCurve *curve1 = new QwtPlotCurve("Curve 1");// copy the data into the curves
curve1->setData(x,y1,100);
curve1->attach(ui->qwtPlot);ui->qwtPlot->replot();
@Anyone
-
wrote on 28 Nov 2011, 12:25 last edited by
Your application doesn't crash, your code raises a compilation error. Most probably because there is no such method setData() which takes two double arrays and an int as a parameter. Take another look at the "documentation":http://qwt.sourceforge.net/class_qwt_plot_series_item.html#adba072515f7c71c923985882129878c4.
-
wrote on 28 Nov 2011, 12:37 last edited by
Yes your right its a compilation problem.
And i tried a setRawData and it worked as I expected.I never used this plot widget before.
-
wrote on 28 Nov 2011, 12:51 last edited by
As Lukas suggested QwtPlotCurve does not have the method setData with this parameter list. You have to use setRawSamples or setSamples in your case. setRawData is not available either according to the documentation.
-
wrote on 28 Nov 2011, 13:22 last edited by
Yes rawSampel is the thing.
Is there anyone with a very simpel example -
wrote on 28 Nov 2011, 13:26 last edited by
qwt comes with examples. Did you try them?
-
wrote on 28 Nov 2011, 13:56 last edited by
yepp and the problem is solved
-
wrote on 24 May 2012, 20:53 last edited by
plotcurve->setSamples() works just fine. I have used it multiple times. Create your X and Y QVector<double> 's and just feed them in.
-
wrote on 17 Jun 2014, 12:40 last edited by
"Here":http://programmingexamples.net/wiki/Qt/QWT/Plot is a simple but complete example.