QCustomPlot Discussion and Comments

How to remove old data points?Return to overview

In the past we have the removeData and removeDataBefore functions. But it seems gone in the new version.
So How can we remove the old data points from a graph to prevent memory overflow?

look in the changelog, there is the new data interface with graph->data()->remove...

I am also missing this feature. There is nothing called graph->data()->remove

There is.
http://www.qcustomplot.com/documentation/classQCPDataContainer.html#aa7f74cbce304b0369e1626c3798e1eda
http://www.qcustomplot.com/documentation/classQCPDataContainer.html#abbe5d87ffc10b5aeffa5bb42cf03aa3c
http://www.qcustomplot.com/documentation/classQCPDataContainer.html#ae5f569a120648b167efa78835f12fd38
http://www.qcustomplot.com/documentation/classQCPDataContainer.html#a2dbded7f0732bacf9db48fdfbbb620bc

Sorry! I was trying to access
plot->graph(0)->data()->clear();
instead of
plot->graph(i)->data().data()->clear();

Thanks for the quick reply

But your first line is also correct, due to the -> operator of QSharedPointer:
http://doc.qt.io/qt-4.8/qsharedpointer.html#operator--gt

You don't need to explicitly call .data() on QSharedPointer, you can directly use

plot->graph(0)->data()->clear(); 

no no no,I test and find that

plot->graph(i)->data().data()->clear();
is work,but
plot->graph(0)->data()->clear();
do not work

Has anyone found a better way to solve the problem of excessive data leading to continuous memory growth? Or is it allowed to write the previous data to the disk?