I'm looking for a way to iterate through items from a composer in QGIS 3, with pyQgis.
First I create a QgsPrintLayout and add it to the layouts manager in my project.
self.newLayout = QgsPrintLayout(projet)
self.newLayout.initializeDefaults()
manager.addLayout(self.newLayout)
Then I load a template to populate the QgsPrintLayout
doc=QtXml.QDomDocument()
doc.setContent(file1, False)
self.newLayout.loadFromTemplate(doc,QgsReadWriteContext())
And I want a list of all the QgsPrintLayout items:
labels = [item for item in self.newLayout.layoutItems()\
if item.type() == QgsComposerItem.ComposerLabel] ...
But Qgis answers:
labels = [item for item in self.newLayout.layoutItems()\
AttributeError: 'QgsPrintLayout' object has no attribute 'layoutItems'
But in doc for QgsLayout (from which QgsPrintLayout takes a part of its methods), I can read:
void layoutItems (QList< T *> &itemList) const
Returns a list of layout items of a specific type. More...
And I really can't find another Public Member function to list all items from a QgsPrintLayer.
What am I missing here?