当前位置: 动力学知识库 > 问答 > 编程问答 >

qt - Qwt: How to delete all items(curves, markers, etc...) from plot

问题描述:

I want to delete all items from my plot. I found this:

plot->detachItems( QwtPlotItem::Rtti_PlotCurve ,true);

plot->detachItems( QwtPlotItem::Rtti_PlotMarker,true);

But, it does not delete clearly. Somethings remains background. I tried on a example. And memory leaks occurs. How can clear all plot?

Thanks for advices.

网友答案:

You should call QwtPlot::replot() after modifying your plot. Add this line after your code:

plot->replot();

Or you can enable auto replot during initialization, QwtPlot::setAutoReplot(true), that way you don't have to call replot every time you change something. On the other hand, if you frequently update your plot, I would advise agains auto replot due to performance reasons. It's better to call replot() explicitly in such case.

分享给朋友:
您可能感兴趣的文章:
随机阅读: