Bug report #10038
Item Properties of the element is not editable on QGISComposer
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | Nyall Dawson | ||
Category: | - | ||
Affected QGIS version: | 2.2.0 | Regression?: | No |
Operating System: | Easy fix?: | No | |
Pull Request or Patch supplied: | No | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 18519 |
Description
When using QGISComposer with a template, the item properties of the element do not appear. To replicate this, you can run this on Python console on QGIS:
from PyQt4 import QtCore, QtXml
canvas = iface.mapCanvas()
renderer = canvas.mapRenderer()
composition = QgsComposition(renderer)template_file = QtCore.QFile('/tmp/inasafe-portrait-a4.qpt')
template_file.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text)
template_content = template_file.readAll()
template_file.close()document = QtXml.QDomDocument()
document.setContent(template_content)
status_load = composition.loadFromTemplate(document)composer = iface.createNewComposer()
composer.setComposition(composition)
Attached is the template file. For more background about this issue, please refer this (https://github.com/AIFDR/inasafe/issues/911). I am sorry if this is not really a bug and we can enable the item properties through the API.
Thanks!
Associated revisions
[composer] Setting the composition for a composer view correctly creates item widgets and sets up connections for composer to composition (fix #10038)
History
#1 Updated by Tim Sutton over 10 years ago
from PyQt4 import QtCore, QtXml canvas = iface.mapCanvas() renderer = canvas.mapRenderer() composition = QgsComposition(renderer) template_file = QtCore.QFile('/tmp/inasafe-portrait-a4.qpt') template_file.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text) template_content = template_file.readAll() template_file.close() document = QtXml.QDomDocument() document.setContent(template_content) status_load = composition.loadFromTemplate(document) composer = iface.createNewComposer() composer.setComposition(composition)
#2 Updated by Nyall Dawson over 10 years ago
- Status changed from Open to Closed
Fixed in changeset a50719b7e9dc23ba4abd24ce6ee859691d1832ee.
#3 Updated by Nyall Dawson over 10 years ago
Fixed in master, but the script MUST set the composition before loading the template:
from PyQt4 import QtCore, QtXml canvas = iface.mapCanvas() renderer = canvas.mapRenderer() composition = QgsComposition(renderer) composer = iface.createNewComposer() composer.setComposition(composition) template_file = QtCore.QFile('/tmp/inasafe-portrait-a4.qpt') template_file.open(QtCore.QIODevice.ReadOnly | QtCore.QIODevice.Text) template_content = template_file.readAll() template_file.close() document = QtXml.QDomDocument() document.setContent(template_content) status_load = composition.loadFromTemplate(document)