how to create the legends which is having line & symbol?
Hi Friends,
i wanted to show the legends in such a way that it should show lines with symbols...
but LegendAttributes doesnot have such option ...it will allow either LegendShowLine or LegendShowSymbol...
like below:
"defaultcurve->setLegendAttribute(QwtPlotCurve::LegendShowLine,t rue);
defaultcurve->setLegendAttribute(QwtPlotCurve::LegendShowSymbol ,true);"
can anyone please suggest how i can achieve the legends which is having both lines with symbols?
Thanks & Regards,
Muthu
Re: how to create the legends which is having line & symbol?
Quote:
Originally Posted by
mammaiap
can anyone please suggest how i can achieve the legends which is having both lines with symbols?
You already posted the correct code.
Unfortunately the layout/render code for the legend is pretty bad in Qwt 6 and you might have effects like that the line is covered by the symbol.
Uwe
Re: how to create the legends which is having line & symbol?
Hi Uwe,
Thanks for your reply...
but what i can do to achieve this??
Regards,
mammaiap
Re: how to create the legends which is having line & symbol?
Well, the first step is to test your legend with a symbol in XCross style, that doesn't cover all space below its bounding rectangle. If the line is visible now we know that both are really painted.
One possible solution to solve your problem is to increase the width for the identifier, so you can see the line in the additional space. This can be done somehow this way:
Code:
{
public:
...
virtual void updateLegend
( QwtLegend *legend
) const {
qobject_cast<QwtLegendItem *>( legend->find( this ) );
if ( legendItem )
{
QSize sz
= symbol
()->boundingSize
();
legendItem->setIdentifierSize(
QSize( 3 * sz.
width(), sz.
height() ) );
}
}
};
Uwe