I am facing a problem with the Layout API while implementing a plugin for QGIS 3. I created a layout template , which contains different elements like map, labels, legend and scale-bar. I'd like to place my legend on the bottom of the page. But the size of the legend can change. So I wanted to place my legend using :
legend = QgsLayoutItemLegend(layout) legend.setLinkedMap(map) legend.setReferencePoint(QgsLayoutItem.LowerLeft) legend.attemptMove(QgsLayoutPoint(page.pageSize().width()*0.79,page.pageSize().height()),useReferencePoint=True)
But this is not working and it gaves me the same result as without the setReferencePoint. So does anyone know why is the "LowerLeft" not working ?
A solution to my problem would be to get the height of my legend and place it from the default UpperLeft position, but I wasn't able to find out how to get that. Any idea on how to get the size of an item ?