[Qgis-developer] Get composer item's size and position

Marco Hugentobler marco.hugentobler at sourcepole.ch
Mon Feb 27 16:51:56 EST 2012


Hi Alex

It might be possible to get the legend size by calling the method 
QgsComposerLegend::paintAndDetermineSize with a 0 pointer as argument to 
get the size:

/**Paints the legend and calculates its size. If painter is 0, only size 
is calculated*/
     QSizeF paintAndDetermineSize( QPainter* painter );

Regards,
Marco

On 27.02.2012 18:50, Alexander Bruy wrote:
> Hi again,
>
> seems it is impossible to get real width and height of the legend
> until composition is not rendered. When legend added to composition
> it always reports width == 4.0 and some height (different for different
> layersets). And only after rendering composition I can get real legend
> width and height.
>
> Maybe there is some trick to get this info without rendering composition?
>
> Thanks


-- 
Dr. Marco Hugentobler
Sourcepole -  Linux&  Open Source Solutions
Churerstrasse 22, CH-8808 Pfäffikon SZ, Switzerland
marco.hugentobler at sourcepole.ch http://www.sourcepole.ch
Technical Advisor QGIS Project Steering Committee



More information about the Qgis-developer mailing list