QwtPlot (v5.1.1) looses connection to legend after I manually clear() and reload legend.
Can't toggle curves off/on.

I've provided this function so users can collapse the legend down to only those curves that are visible in QwtPlot area.

QwtPlot legendChecked(QwtPlotItem*, bool) signal doesn't appear to be "Emitted" after my simplifyLegend() method (see src below) is called. I suspect this because I have a slot that's connected to the legendChecked() signal, and it's never entered if my simplifyLegend function is called prior to the legendChecked event.
Note: Everything works fine (I can toggle curves off/on) if I don't call my simplifyLegend().

Any Ideas?

Here's the function:

void SingleLogTrack::simplifyLegend(bool on) {

m_plotItems = itemList();
m_legend->clear();

foreach (QwtPlotItem *plt_item, m_plotItems) {
QwtLegendItem* lgd_item = new QwtLegendItem();
if ( plt_item->rtti() == QwtPlotItem::Rtti_PlotCurve ) {
QwtPlotCurve *c = (QwtPlotCurve*)(plt_item);
lgd_item->setText(c->title().text());
lgd_item->setSymbol(c->symbol());
lgd_item->setCurvePen(c->pen());
lgd_item->setItemMode(QwtLegend::CheckableItem);
if (c->style() == QwtPlotCurve::NoCurve)
lgd_item->setIdentifierMode(QwtLegendItem::ShowSymbol);
else
lgd_item->setIdentifierMode(QwtLegendItem::ShowLine);
lgd_item->setChecked(c->isVisible());
}

if (plt_item->title().text() != "Marker" &&
plt_item->title().text() != "Grid") {
if (on) {
if (plt_item->isVisible()) m_legend->insert(plt_item,lgd_item);
} else {

m_legend->insert(plt_item,lgd_item);
}
}
}
replot();

}