[Qgis-developer] How to get Composer's name/title using Python

Nyall Dawson nyall.dawson at gmail.com
Mon Sep 8 05:12:38 PDT 2014


On 8 September 2014 21:52, Alexandre Neto <senhor.neto at gmail.com> wrote:
> Hello all,
>
> For an expression function I'm trying to select a composition by searching
> for the composer name/title.
>
> I know I can get all active composers by using:
>
>> composers = iface.activeComposers()
>
>
> I can then access to the QgsComposerView by iterating the composers list:
>
>> for composer_view in composers:
>>     print composer_view
>
>
> and that in the composerview there is a QgsComposition:
>
>> composition = composer_view.composition()

It's not stored in QgsComposition (unfortunately... this needs to
change sometime!). Try:

for composer_view in composers:
   print composer_view.composerWindow().windowTitle()


Nyall


More information about the Qgis-developer mailing list