I\'m new to PyQt.
I\'m trying to put a QTableView in a class, so I can define it\'s behaviour in the class without mixing it with all the other code, but when I do so it
the problem: table.view has no parent. If you add self.view.show()
to test to Table.initUi()
, you get two widgets, MyWindow
with empty table as tmoreau wrote and table.view
as isolated widget.
You can either pass a parent when constructing table.view
in Table.initUi()
self.view = QTableView(self)
(then you don't need a layout) or add table.view to a layout as written by tmoreau, Then the tableview is reparented.
Removing the class has the same effect, then the tableview is added to layout.