[QGIS-Developer] QgsComposition.getComposerItemById returns wrong object

Enrico Ferreguti enricofer at gmail.com
Sun Jan 7 01:27:38 PST 2018


Thanks Nyall, I will wait for that.

Il 07/gen/2018 02:08, "Nyall Dawson" <nyall.dawson at gmail.com> ha scritto:

> On 7 January 2018 at 08:13, Enrico Ferreguti <enricofer at gmail.com> wrote:
> > I'm trying to set programmatically a QgsComposerPicture content in
> QGIS2.99:
> >
> > 1) I create a new print composition and I name it 'test'
> > 2) I create a picture frame in the composition and I call it 'picture'
> > 3) I run the following code:
> >
> > from qgis.core import QgsProject
> > myComposition =
> > QgsProject.instance().layoutManager().compositionByName('test')
> > myComposerPicture = myComposition.getComposerItemById("picture")
> > myComposerPicture.setPicturePath("[path to an image]")
> >
> > and I get the following Exception:
> > AttributeError: 'QgsComposerItem' object has no attribute
> 'setPicturePath'
> >
> > If I inspect myComposerPicture object I found it is a
> > qgis._core.QgsComposerItem not a QgsComposerPicture
> >
> > Is this a correct behaviour or is it an issue?
> > Should I open a issue ticket?
>
> If your script is targeting QGIS 3.0, please don't file bugs against
> composer. You need to use the newer layouts engine instead (QgsLayout
> and associated classes).
>
> Over the coming week all composer code will be removed from QGIS.
>
> Nyall
>
> >
> >
> > _______________________________________________
> > QGIS-Developer mailing list
> > QGIS-Developer at lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180107/42ca7a1a/attachment.html>


More information about the QGIS-Developer mailing list