Hiding and displaying legend items not working in 6.1 as did in 6.0
Hi,
I'm porting to Qwt 6.1 from 6.0 and am having touble getting legend items to hide and display themselves, depending on wheather they are being displayed in a QwtPlot chart. Any hints? Any help much appreciated.
Below is a method for 6.0 that worked, and below that is the same method i'm trying to implement for 6.1 that doesn't work. All of the code below implemented in a QwtPlot subclass.
Code:
void SingleLogTrack::slotSimplifyLegend(bool on) { // works for Qwt 6.0
bool showit = true;
if ( plt_item
->rtti
() == QwtPlotItem::Rtti_PlotCurve ) {
if (on) showit = c->isVisible();
if (!on) {
QWidget *w
= legend
()->find
(plt_item
);
if ( w && w->inherits("QwtLegendItem" ) ) {
}
}
}
}
}
Code:
void SingleLogTrack::slotSimplifyLegend(bool on) { // not yet working for Qwt 6.1
bool showit = true;
if ( plt_item
->rtti
() == QwtPlotItem::Rtti_PlotCurve ) {
if (on) showit = c->isVisible();
if (!on) {
QwtLegend *lgd
= qobject_cast<QwtLegend
*>
(legend
());
QList<QWidget *> legendWidgets = lgd->legendWidgets(itemToInfo(plt_item));
if ( legendWidgets.size() == 1 ) {
QwtLegendLabel *b = qobject_cast<QwtLegendLabel *>(legendWidgets[0]);
if ( b && b->inherits("QwtLegendLabel") )
((QwtLegendLabel *)b)->setChecked(c->isVisible());
}
}
}
}
}
Re: Hiding and displaying legend items not working in 6.1 as did in 6.0
What exactly doesn't work: hiding/showing or setting of the checked state ?
Uwe
Re: Hiding and displaying legend items not working in 6.1 as did in 6.0
Uwe, thanks for the reply. I immediately noticed that hide/show isn't working. The debugger tells me that plot item iteration is working, but nothing appears to happen. Sorry, can't give you more details, not in the office today.
Re: Hiding and displaying legend items not working in 6.1 as did in 6.0
When looking at the code of QwtPlotItem::legendChanged() I would expect, that the hide is not working.
Simply call "updateLegend()" manually at the end of SingleLogTrack::slotSimplifyLegend.
Uwe
Re: Hiding and displaying legend items not working in 6.1 as did in 6.0