[Qgis-developer] Handling deprecation of QgsMapCanvas.mapRenderer()
Jürgen E. Fischer
jef at norbit.de
Wed Sep 17 10:02:25 PDT 2014
Hi Tom,
On Wed, 17. Sep 2014 at 14:43:29 +0000, Tom Chadwin wrote:
> Is that correct? If so (as a QGIS plugin and Python beginner) what is the
> best way to handle the deprecation and maintain backwards compatibility,
> given that QgsMapCanvas.mapRenderer() is only in 2.4+?
You could use:
try:
crs = c.mapSettings().destinationCrs()
except:
crs = c.mapRenderer().destinationCrs()
or shorter:
crs = c.mapSettings().destinationCrs() if hasattr(c,"mapSettings") else c.mapRenderer().destinationCrs()
Jürgen
--
Jürgen E. Fischer norBIT GmbH Tel. +49-4931-918175-31
Dipl.-Inf. (FH) Rheinstraße 13 Fax. +49-4931-918175-50
Software Engineer D-26506 Norden http://www.norbit.de
QGIS release manager (PSC) Germany IRC: jef on FreeNode
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140917/c05c228a/attachment.pgp>
More information about the Qgis-developer
mailing list