1

I originally use C Programming language. But Now, I need to use Qt programming (by the way, Qt is like a dream). I am going to more depth step by step. But my C++ object oriented knowledge is weak, I hope that it will be stronger. Nowadays I have to use Qwt and I stucked in QwtSeriesData object. I need to know how can I set a series of data to this object in order to draw a curve with using QwtPlot.

For example my data is like below, how can I set them into QwtSeriesData.

float x[300]; float y[300];

Thanks.

adba
  • 477
  • 9
  • 25
  • I do not use Qwt, but since no one was addressing this I looked. QwtSeriesData isn't a concrete object...it's an abstract interface. So there's nothing to set. What you need to do is find an object that speaks the QwtSeriesData protocol (or write one yourself), then set the data inside that object. You might try adapting a sample that's similar to your situation, and edit your question to include the code you're trying... – HostileFork says dont trust SE Dec 09 '11 at 10:42
  • Actually, I found the solution of my problem. I used another function named as QwtPlotCurve::setRawSamples. But this solution is not an answer for this question, so I don't know what I can do for this question. – adba Dec 10 '11 at 11:02

2 Answers2

1

This is how I do it:

QwtPlotCurve* curve = new QwtPlotCurve;
QPolygonF points;
for(unsigned int i = 0; i < 300; i++)
{
  points << QPointF(x[i], y[i]);
}
curve->setSamples(points);

you then need to attach the curve to the plot.

natty
  • 11
  • 2
1

My answer is for latest qwt version 6.x.x (latest for current moment) Note: qwt internally uses double for data representation, not float. So you either should use double or you would need to implement your own QwtSeriesData implementation which holds float in memory but provides double for requests of external components (that's a really bad way of doing things)

You can use one of subclasses of QwtSeriesData provided by the qwt: QwtCPointerData or QwtPointArrayData.

Sergey P. aka azure
  • 3,993
  • 1
  • 29
  • 23