Bug report #10038

Item Properties of the element is not editable on QGISComposer

Added by Akbar Gumbira over 10 years ago. Updated over 10 years ago.

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!

inasafe-portrait-a4.qpt (13.5 KB) Akbar Gumbira, 2014-04-09 06:41 AM

Associated revisions

Revision a50719b7
Added by Nyall Dawson over 10 years ago

[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

#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)

Also available in: Atom PDF