From Showing attribute table in form using PyQGIS I know how to show a table with all the attributes using this code:
cache = QgsVectorLayerCache(layer, 10000)
model = QgsAttributeTableModel(cache)
model.loadLayer()
table = QTableView()
table.setModel(model)
Now I'm wondering how to show not all the attributes, but only the ones I want or, if it's possible, do the same thing with the classic attribute table.
iface.showAttributeTable(my_layer)) and you'll see some columns are now hidden. – Germán Carrillo Dec 14 '19 at 18:26