Is there a way to to have a map (Print Composer) open automatically upon project load?
I have a map constructed in Print Composer "General Map".
When a user fires off the project, I would like "General Map" to open by default.
Is there a way to to have a map (Print Composer) open automatically upon project load?
I have a map constructed in Print Composer "General Map".
When a user fires off the project, I would like "General Map" to open by default.
I'm not aware of any way to designate the print composer to open as a default action of the QGIS software. Also, I'm not sure if there is a plug-in either, I would imagine if there was this capability available it would be available as a plug-in unless the QGIS developers move to having the print composer open as a default option.
Furthermore, I came across a discussion in a different forum that discusses the thought process amongst some QGIS developers about the reason to not having this as a default option but rather encouraging users to utilize the template load option for customization of each print composer for a particular project.
As @whyzar already mentioned, I don't think there's a setting or plugin which could achieve this directly (not yet anyway).
However, you can achieve this by using a Python script inside a macro (script adapted from this post, credit to @Matt) which runs whenever the project is loaded. Note that the Print composer template must be saved separately as the following script loads this .qpt file:
import os, qgis
from PyQt4.QtXml import QDomDocument
# Change path and name of template accordingly
myFile = os.path.join('C:/Users/You/Desktop//', 'General Map.qpt')
myTemplateFile = file(myFile, 'rt')
myTemplateContent = myTemplateFile.read()
myTemplateFile.close()
myDocument = QDomDocument()
myDocument.setContent(myTemplateContent, False)
newcomp = qgis.utils.iface.createNewComposer()
newcomp.composition().loadFromTemplate(myDocument)
From the toolbar, insert the script in:
Project > Project Properties... > Macros
Make sure you do the following:
Now when the project is loaded, the composer template should pop up.