Sangfeust
5th February 2015, 14:29
Hello,
I am using the legend to show/hide my curve and it works fine.
But I am looking for a way to set the QwtLegendLabel of the curve to SET when attached to the plot...
Can someone help me?
I have not find how to reach easyli QwtLegendLabel of a curve...
I use this to show/hide:
void GraphB::showCurve( QwtPlotItem *item, bool on )
{
// Show/hide the curve
item->setVisible( on );
// Get QwtLegend .... but why
QwtLegend *lgd = qobject_cast<QwtLegend *>( legend() );
// List of widget from QwtLegend associate to item
QList<QWidget *> legendWidgets =
lgd->legendWidgets( itemToInfo( item ) );
// ????
if ( legendWidgets.size() == 1 )
{
// legendLabel is the frame of the legend label
QwtLegendLabel *legendLabel =
qobject_cast<QwtLegendLabel *>( legendWidgets[0] );
// If we have the object check it
if ( legendLabel )
legendLabel->setChecked( on );
}
replot();
}
I am also looking for a method to hide the yAxis of the QwtPlotCurve... if someone has already done something :)
Thanks
Sangfeust
I am using the legend to show/hide my curve and it works fine.
But I am looking for a way to set the QwtLegendLabel of the curve to SET when attached to the plot...
Can someone help me?
I have not find how to reach easyli QwtLegendLabel of a curve...
I use this to show/hide:
void GraphB::showCurve( QwtPlotItem *item, bool on )
{
// Show/hide the curve
item->setVisible( on );
// Get QwtLegend .... but why
QwtLegend *lgd = qobject_cast<QwtLegend *>( legend() );
// List of widget from QwtLegend associate to item
QList<QWidget *> legendWidgets =
lgd->legendWidgets( itemToInfo( item ) );
// ????
if ( legendWidgets.size() == 1 )
{
// legendLabel is the frame of the legend label
QwtLegendLabel *legendLabel =
qobject_cast<QwtLegendLabel *>( legendWidgets[0] );
// If we have the object check it
if ( legendLabel )
legendLabel->setChecked( on );
}
replot();
}
I am also looking for a method to hide the yAxis of the QwtPlotCurve... if someone has already done something :)
Thanks
Sangfeust