QCustomPlot clear Data
-
I think Ian explained rather clearly what you can or can not do. I don't see how we could add to that.
wrote on 2 Feb 2017, 12:40 last edited by@kshegunov I dont want to set empty data . I was searching for fallowing code which is shared by mrjj.
-
wrote on 2 Mar 2017, 09:01 last edited by
Hi,
I'm facing some issue with ui->qcustom->graph(0)->data()->clear();. It is not working for me.
Data container is not getting cleared, even if i call clear() and then replot().
Pls help.
Thank you. -
wrote on 22 Jun 2017, 21:17 last edited by
I have the same problem as indu2. Calling clear() and replot(), nothing happens
-
wrote on 26 Jun 2017, 19:47 last edited by mrjj
Try ui->yourPlot->clearPlottables();
-
wrote on 9 Oct 2017, 13:44 last edited by
clearPlottables() does not work because it deletes the object entirely.
-
Hi
Maybe ask the author of customplot about how to do it correctly then? -
wrote on 5 Dec 2017, 13:31 last edited by
Try:
for( int g=0; g<pq_plot->graphCount(); g++ ) { pq_plot->graph(g)->data().data().clear(); } pq_plot->replot();
don't know why to use ->data().data() but it works for me.
-
wrote on 25 Dec 2019, 16:46 last edited by
@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
-
@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.
wrote on 26 Dec 2019, 06:07 last edited by@Joel-Bodenmann It was so helpful for me, thanks.
- If you do
-
@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.
wrote on 12 Feb 2021, 02:54 last edited by@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. - If you do