QwtPlotCurve: how to delete/erase/empty the Data?
Hello,
is there any possibility to clear the Data in a QwtPlotCurve object?
like: QwtPlotCurve MyCurve; MyCurve.clear(); or MyCurve.data.clear();
I've seen QwtPlot has a clear() function available.
I have "QwtPlotCurve MyCurve" objects living in mainwindow.cpp all the time. The only way to delete the Objects is with delete MyCurve and Creating it again with the new operator.
But i need the QwtPlotCurve- objects to be alive, the whole time.
In the case i have to implement this by myself, the Data in QwtPlotCurve is private... so i cannot inherit it?
thanks Astronomy
Re: QwtPlotCurve: how to delete/erase/empty the Data?
curve->setData(QwtArray<QwtDoublePoint>());
Uwe
Re: QwtPlotCurve: how to delete/erase/empty the Data?
Hi Uwe,
thanx for the reply.
that 's actually what i'm doing now. But with a QVector<double> Data and; curve->setData( Data1 ); and overwriting it with new Data..
The Question is:
1) If Data1 has 100 Entries and Data2 has less entries, eg. Data2[20] ; curve->setData( Data2 ) what does happen? Are the last 80 Entries the Old Data?
2) Or is the Memory, which was first located for 100 Entries now freed? Or are 80 Entries reserved with 0.0
( I have really big Data...) i'm going to debug 1) + 2)..
3) If you suggest with curve->setData(QwtArray<QwtDoublePoint>());, a simple overwrite, i have to overwerite the whole size of the Array with "0.0" for doing the clear() job?
Background:
I'm using CZoomer for zooming and i'm loading several Data1,2,3,.... in QwtPlot MyPlot two QwtPlotCurve MyCurve1 and QwtPlotCurve MyCurve2.
And for unknown reasons the Data i've erased from MyCurve, is sudden visible again if i zoom out? Maybe it's an CZoomer problem, but i was thinking, that it is because of QwtPlotCurve has no nice clear() Funktion?
greetings Astronomy
Re: QwtPlotCurve: how to delete/erase/empty the Data?
Ah i just found out:
So SetData does make a total clearance if new data is inserted.
Quote:
void QwtPlotCurve::setData(const QPolygonF &data)
#endif
{
delete d_xy;
d_xy = new QwtPolygonFData(data);
itemChanged();
}
or
void QwtPlotCurve::setData(const QwtData &data)
{
delete d_xy;
d_xy = data.copy();
itemChanged();
}
Re: QwtPlotCurve: how to delete/erase/empty the Data?
Thanks to Uwe the trick with: curve->setData(QwtArray<QwtDoublePoint>());
worked.
I do not quite understand why ::setData(const QPolygonF &data) needs a new operator in the implementation and ::setData(const QwtData &data) below not. As i know, after each delete must follow a new operator? But as long as it works it should not bother me (-;
regards A.