I am trying to find information about how to programmatically import new composer from template, but it is impossible.

There is a lot of information how to print the composer to image, but not save it in the project *.qgs.

Has anyone got any experience of loading new composer to project QGIS and open it from list "Print composers"?


1 Answer 1


This is solve for me.

myFile = os.path.join('r:/Graf/_temp/Templates/', 'template.qpt')
myTemplateFile = file(myFile, 'rt')
myTemplateContent = myTemplateFile.read()
myDocument = QDomDocument()
myDocument.setContent(myTemplateContent, False)
newcomp = self.iface.createNewComposer()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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