I'm trying to develop a plugin in QGIS 2.6, which opens a composer, add a map and a legend, and (among other things) adjusts the legend.
Is there a way to go through items in a composer legend with PyQgis? What I'd want in the end is to change the item name, depending on the type of item (group, raster ...).
Here is my code:
for legend in self.composition.items():
if isinstance(i,QgsComposerLegend):
legend.setAutoUpdateModel(True)
legend.setLegendFilterByMapEnabled(True)
for item in legend.items():
if item.itemtype() == QgsComposerLegendItem.GroupItem:
groupItem.setUserText() = 'another text'
Qgis answers that QgsComposerLegend has not attribute called "items" (which I expected). I looked for a property to iterate on legend items, and I have not found it in the API documentation nor in web searches.
No comments:
Post a Comment