Showing the composition in QGIS

المشرف العام

Administrator
طاقم الإدارة
I´m currently using QGIS 2.8.1 and have create a plugin with the pluginbuilder.

I´m trying to create a composed layout and want to show the layoutcomposer to the user at the end. I´ve done the following so far

mapRenderer = self.iface.mapCanvas().mapRenderer()

composition = QgsComposition(mapRenderer)

composition.setPlotStyle(QgsComposition.Print)

x, y = 0, 0

w, h = composition.paperWidth(), composition.paperHeight()

composerMap = QgsComposerMap(composition, x,y,w,h)

composition.addItem(composerMap)

composerLabel = QgsComposerLabel(composition)

composerLabel.setText("Hello world")

composerLabel.adjustSizeToText()

composition.addItem(composerLabel)

But where do I go from here.I´ve seen examples like:

composerList=iface.activeComposers()

composerView=composerList[composerList.index(max(composerList))]

composer = composerView.composerWindow()

composer.show()

But when I run the code, the composerList is empty.

Any suggestions/comments are greatly appreciated

Regards

Kaare

ps: Does anyone know how to set the name for the current layout?



أكثر...
 
أعلى