[SOLVED]QWT plot doesn’t like my array
-
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
-
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.
-
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.
-
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.
-
Yes rawSampel is the thing.
Is there anyone with a very simpel example -
qwt comes with examples. Did you try them?
-
yepp and the problem is solved
-
plotcurve->setSamples() works just fine. I have used it multiple times. Create your X and Y QVector<double> 's and just feed them in.
-
"Here":http://programmingexamples.net/wiki/Qt/QWT/Plot is a simple but complete example.