So my QwtPlot is populated with data and plotted when the user imports a file. The data can also be scaled in realtime using some combo boxes. The problem I am having is if the user imports another file then the other plot curves and the corresponding legend items are not being deleted. I am using:

this->detachItems(QwtPlotItem::Rtti_PlotCurve);

Which in the case that I am rescaling the curves works perfectly fine, but for some reason when I re-import a file the curves do not get deleted. Any ideas to why this might be happening?