PDA

View Full Version : help using QLists as data in QwtPlotCurve



esorensen
11th July 2008, 17:07
Hi,

I have 2 QLists that I would like to use as the data in a QwtPlot.
(xList, yList)

I see that QwtPlotCurve has several methods for setData;

void setData (const double *xData, const double *yData, int size)
void setData (const QwtArray< double > &xData, const QwtArray< double > &yData)
void setData (const QPolygonF &data)void setData (const QwtData &data)

Simply trying

pCurve->setData( Data->xList, Data->yList );

produces the error

error: no matching function for call to
'QwtPlotCurve::setData(const QList<double>&, const QList<double>&)'


It looks like I should be able to use the method

void setData (const QwtArray< double > &xData, const QwtArray< double > &yData)

if I were smart enough.

Is there an easy / inexpensive way to use my existing QLists as the data?

Thanks for any help.

es

Uwe
11th July 2008, 20:52
QList might be the right solution for your situation, but in general its a bad decision for storing large datasets of doubles. That's why tere is no QwtData class that is tailored for it.

If you really need fast insertion/removals in your data-sets ( that's what QList is good for ) and want to stay with QList I recommend to derive your own QwtListData class. Simply copy QwtArrayData and replace QwtArray by QList.

Uwe