I Googled the deprecation message and the only result was a GIS.se question I asked that referenced the error. Despite this constructor having been deprecated in QGIS 2.4, there's a recent question still using the deprecated construction, and one of the highest voted answers on the topic relies on it as well:

renderer = QgsMapRenderer()
myComposition = QgsComposition(myMapRenderer)
with open(template_composer, 'r') as template:
    new_composer_content = template.read()
    new_composer_document = QDomDocument()

How should I update this code for PyQGIS versions greater than 2.4?


1 Answer 1


I tried your code and with a few tweaks, got it to "work" (or throw that message)

Had a rummage around in the QGIS source code on github, and came across this commit from earlier this year

search the page for QgisComposition and you'll see

//! @deprecated since 2.4 - use the constructor with QgsMapSettings
-    QgsComposition( QgsMapRenderer* mapRenderer ) /Deprecated/;
explicit QgsComposition( const QgsMapSettings& mapSettings );

The line starting '-' has been deleted. So it looks like you need to pass a QgsMapSettings, not a QgsMapRenderer , to the constructor.

Not the answer you're looking for? Browse other questions tagged or ask your own question.