I am trying to insert a qgis attribute table to a layout using Visual Studio Code, how would I do it?
layout = project.layoutManager().layoutByName('nombre_layout')
table = QgsLayoutItemAttributeTable(layout)
layer = QgsProject.instance().mapLayersByName('nombre_capa')[0]
table.setVectorLayer(layer)
table.setDisplayOnlyVisibleFeatures(True)
table.setDisplayHeader(True) #This line doesn't work
layout.addLayoutItem(table)
table.attemptResize(QgsLayoutSize(150, 150, QgsUnitTypes.LayoutMillimeters))
table.attemptMove(QgsLayoutPoint(10, 10, QgsUnitTypes.LayoutMillimeters))
I get the error:
File "c:\Users\Desktop\Proyectos\PyQgis\script.py", line 174, in table.setDisplayHeader(True) #This line doesn't work AttributeError: 'QgsLayoutItemAttributeTable' object has no attribute 'setDisplayHeader'
setDisplayHeader
to do?