2

I'm trying to work through this answer in the QGIS (2.14) Python console to understand, ultimately, how to iterate over layers and print them with a template.

When I run the following code block.

I get a NameError that QDomDocument() is undefined.

myComposition = QgsComposition(myMapRenderer)
myFile = os.path.join(os.path.dirname(__file__), 'MMR_Template.qpt')
myTemplateFile = file(myFile, 'rt')
myTemplateContent = myTemplateFile.read()
myTemplateFile.close()
myDocument = QDomDocument()

Possibly related (can split into a separate question) I also get the warning DeprecationWarning: QgsComposition constructor is deprecated but can find nothing about this warning on Google.

raphael
  • 3,407
  • 23
  • 61

1 Answers1

2

From this comment, adding the following line to the console script resolved this issue in 2.14 to 2.18.2

from qgis.PyQt.QtXml import QDomDocument
raphael
  • 3,407
  • 23
  • 61