PDA

View Full Version : QwtPlotLegendItem empty data



atrofimov
15th April 2015, 19:25
I'm add QwtPlotLegendItem to QwtPlot without the curves.
Empty rect displayed. See attach.

Function code:
QRect QwtPlotLegendItem::geometry( const QRectF &canvasRect ) const
{
QRect rect;
rect.setSize( d_data->layout->sizeHint() );

As a result, the function returns a non-empty rectangle.

I fixed it in the derived class like this:
QRect MyLegendItem::geometry(const QRectF &canvasRect) const
{
QRect r = QwtPlotLegendItem::geometry(canvasRect);
if (r.width() < 0 || r.height() < 0)
r = QRect();
return r;
}

Need to add content checking.
What do you think about this?

Uwe
17th April 2015, 06:57
I changed QwtPlotLegendItem::draw() not drawing something, when having an empty geometry. Fixed in all SVN branches >= 6.1,

Uwe

atrofimov
17th April 2015, 14:23
Uwe,
Thank you ever so!