QCustomPlot clear Data
-
@HafsaElif
There is
graph->data()->clear();
Since the 2.0 beta version.Alternatively, you can simply give it an empty data list.
Then its "Clear". -
Hi
Maybe ask the author of customplot about how to do it correctly then? -
@Scarab said in QCustomPlot clear Data:
don't know why to use
->data().data()
but it works for me.The type returned by
QCPGraph::data()
is a shared pointer to the data container. Both the shared pointer as well as the object the shared pointer is pointing to have aclear()
function:- If you do
pq_plot->graph(g)->data().clear()
you are callingQSharedPointer::clear()
. - If you do
pq_plot->graph(g)->data()->clear()
you're callingQCPGraphDataContainer::clear()
- which is what you actually want.
Calling
pq_plot->graph(g)->data().data().clear()
(as per your example) effectively callsQCPGraphDataContainer::clear()
becauseQSharedPointer::data()
returns the raw pointer managed by the shared pointer.
Therefore,pq_plot->graph(g)->data().data().clear()
andpq_plot->graph(g)->data()->clear()
are equivalent.I hope this helps to prevent confusion for people that come across this in the future.
- If you do
-
@Joel-Bodenmann It was so helpful for me, thanks.
-
@Joel-Bodenmann said in QCustomPlot clear Data:
iner::clear()
I have tested for one hour, the memory grow from 8192k to 9600k,when i call clear(),the memory is still 9600k, seems not release.