PDA

View Full Version : How to get same icon size in QwtLegendItem for each entry? (fixed width)



HappyCoder
3rd March 2016, 11:58
Hello,

i have a QwtLegendItem that shows attached Plots
and attached QwtPlotShapeItems. The have all different
width of the icon left of theier name in QwtLegendItem.

11761

How can i realize, that all have the same icon (symbol) width in QwtLegendItem?

Thx

Uwe
4th March 2016, 08:33
What about using: shapeItem->setLegendIconSize( ... ) ?

Uwe

HappyCoder
7th March 2016, 07:43
I do that already for the shapeItem with QSize(18x10). The problem ist not the shapeItem,
the problems are the curveItems.
I tried that also for curveItem with no effect, the LegendIconSize of a curve doesn'nt change.
A curve without symbol has a small legendItcon and a curve with symbol has a much bigger symbol in width.
That is shown in the picture.

Stefan

PS: the main problem for curveItem is qwtUpdateLegendIconSize, that is a static method in QwtPlotCurve and can't be override.

Uwe
8th March 2016, 07:13
PS: the main problem for curveItem is qwtUpdateLegendIconSize, that is a static method in QwtPlotCurve and can't be override.

class YourCurve: public QwtPlotCurve
{
...
virtual QwtGraphic legendIcon( int index, const QSizeF &size ) const
{
QSizeF extendedSize;
extendedSize.setHeight( size.height() );
extendedSize.setWidth( ... );

return QwtPlotCurve::legendIcon( index, extendedSize );
}
};Uwe

HappyCoder
8th March 2016, 13:19
Excellent Uwe !!! Exactly what i was looking for. :)
Thank You!