[Qgis-developer] setting QgsMapCanvas size, for testing map tools

Sandro Santilli strk at kbt.io
Fri Jul 1 10:17:35 PDT 2016


On Fri, Jul 01, 2016 at 06:47:16PM +0200, Martin Dobias wrote:

> I think what you are up to is not to find out scale(), but actually
> mapUnitsPerPixel(). Scale in QGIS is calculated as ( extent_width / (
> canvas_width * dpi) ) with some extra conversions involved, see
> QgsScaleCalculator class.

Thanks, with the show() trick, mapUnitsPerPixel() works as expected
(while scale() still gives wild returns, maybe due to wild dpis..)

--strk;


More information about the Qgis-developer mailing list