I have created a plugin using the Plugin Builder plugin, and I tried to adapt it to show a QgsAttributeTable (by following this example). I get absolutely no errors or warnings, but it simply shows an empty white box. Do you have any suggestions for what I should try?
class FooDockWidget(QtWidgets.QDockWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setWindowTitle('This_is_the_window_title!!!')
widget = QWidget(self)
self.setWidget(widget)
layout = QVBoxLayout(widget)
widget.setLayout(layout)
layer = iface.activeLayer()
assert layer is not None
canvas = iface.mapCanvas()
vector_layer_cache = QgsVectorLayerCache(layer, 10000)
attribute_table_model = QgsAttributeTableModel(vector_layer_cache)
attribute_table_model.loadLayer()
attribute_table_filter_model = QgsAttributeTableFilterModel(canvas, attribute_table_model)
attribute_table_view = QgsAttributeTableView()
attribute_table_view.setModel(attribute_table_filter_model)
layout.addWidget(attribute_table_view)