I have an attribute table in my layout, defined as follow :
layout = QgsPrintLayout(project)
layout.initializeDefaults()
QgsProject.instance().layoutManager().addLayout(layout)
pdf = QgsProject.instance().mapLayersByName('plan_de_ferme')[0]
pdf_table = QgsLayoutItemAttributeTable.create(layout)
pdf_table.setVectorLayer(pdf)
pdf_fields = ['champ','sup','supepnd']
pdf_table.setDisplayedFields(pdf_fields, True)
I would like to rename the fields name displayed in the layout without changing the fields name in the layer.
I tried :
pdf_headers = ['Champ','Superficie (ha)','Superficie épandable (ha)']
pdf_table.setHeading(pdf_headers)
Like it's the way to do with a QgsLayoutItemTextTable
, but it's not working because "AttributeError: 'QgsLayoutItemAttributeTable' object has no attribute 'setHeading'"
.