[QGIS-Developer] QgsLayout.itemById returns wrong object
Enrico Ferreguti
enricofer at gmail.com
Tue Jan 23 04:34:19 PST 2018
I'm trying to programmatically set a QgsLayoutPicture content in QGIS3.0:
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
myLayout = QgsProject.instance().layoutManager().layoutByName('test')
myLayoutPicture = myLayout.itemById("picture")
myLayoutPicture.setPicturePath("path to an image")
and I get the following Exception:
AttributeError: 'QgsLayoutItem' object has no attribute 'setPicturePath'
If I inspect myLayoutPicture object I found it is a
qgis._core.QgsLayoutItem not a QgsLayoutPicture
Is this a correct behaviour or is it an issue? How can I get the right
Layout object?
Regards.
Enrico Ferreguti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180123/fbd340aa/attachment.html>
More information about the QGIS-Developer
mailing list