PDA

View Full Version : QwtLegendItem should show only checked entrys of QwtLegend (or visible PlotItems)



HappyCoder
20th July 2015, 09:33
Hello,

With the QwtLegend i manage the visibility of curves, markers etc. that are attached to to plot.
I can't use the attribute QwtPlotItem::Legend, because if i set it to false it disapears from QwtLegend.

The QwtPlotLegendItem inside of plot should show ONLY the visible items of the plot. How can i do this?

Stefan

Uwe
21st July 2015, 08:41
With the QwtLegend i manage the visibility of curves, markers etc. that are attached to to plot.
I can't use the attribute QwtPlotItem::Legend, because if i set it to false it disapears from QwtLegend.
Yes of course: setting QwtPlotItem::Legend to false has the meaning of not being relevant for the legend.



The QwtPlotLegendItem inside of plot should show ONLY the visible items of the plot. How can i do this?
Overload QwtPlotLegendItem::updateLegend(), something like this:


virtual void YourLegendItem::updateLegend( const QwtPlotItem *plotItem,
const QList<QwtLegendData> &data )
{
if ( !plotItem->isVisible() )
QwtPlotLegendItem::updateLegend( plotItem, QList<QwtLegendData>() );
else
QwtPlotLegendItem::updateLegend( plotItem, data );
}