I am developing a a plugin in QGIS. I want to add attribute table of a vector layer as data model in QTableView. I am using following lines of code but it is adding empty column.
vector_layer_cache = QgsVectorLayerCache(select_op, 10000)
attribute_table_model = QgsAttributeTableModel(vector_layer_cache)
attribute_table_model.loadLayer()
self.dlg.tableView.setModel(attribute_table_model)
How to get full attribute table displayed in QTableView/QTableWidget?
QgsAttributeTableView.setModel()does not receive a parameter of typeQgsAttributeTableModelbut aQgsAttributeTableFilterModelinstead, where you can set a filter to show all features. Look at https://gis.stackexchange.com/questions/425009/how-to-show-the-attribute-table-inside-the-dialogue-of-a-custom-plugin-with-qgis/425042 – CodeBard Mar 10 '22 at 08:18self.attribute_table_model =instead ofattribute_table_model =etc. – CodeBard Mar 10 '22 at 11:28