5

In the earlier versions of Qwt we add QwtPlot::clear() but now, I can't find it.

Any ideas? I have a real time plot, so when replotting, the info before xmin is not really important and with time it crashes as the replot is replotting all the information before xmin.

SamuelNLP
  • 4,038
  • 9
  • 59
  • 102

2 Answers2

5

The method Qwtplot::clear() has been deprecated. Use QwtPlotDict::detachItems instead.

void QwtPlotDict::detachItems(int rtti = QwtPlotItem::Rtti_PlotItem, 
                              bool autoDelete = true 
                             )

Parameters:

rtti: In case of QwtPlotItem::Rtti_PlotItem detach all items otherwise only those items of the type rtti. autoDelete: If true, delete all detached items

bruno
  • 2,802
  • 1
  • 23
  • 23
  • well, I used this ` for (int i = 0; i < 8; i++) { plot_all[i]->detachItems(QwtPlotItem::Rtti_PlotItem, true); plot[i]->detachItems(QwtPlotItem::Rtti_PlotItem, true); }`and it didn's detach the `QwtCurves` – SamuelNLP Mar 13 '13 at 14:16
  • 1
    what happens when you call the function with no arguments? Like plot_all[i]->detachItems(); – bruno Mar 13 '13 at 14:24
2

one of the way to clear plot is to set your data points to empty: for example: (m_vctTime,m_vctValue -vector) (curve=new QwtPlotCurve()) (plot=new QwtPlot(parent))

m_vctTime.clear();
m_vctValue.clear();
curve->setSamples(m_vctTime,m_vctValue);
plot->replot();    

that clears your plot

AlexBee
  • 368
  • 3
  • 13