I ran into an issue when attempting this.
I have a separate python file that has a single class which is based on a QTableWidget. I pass parameters to the init and set various class instance variables for the parameters passed. I have a methods for initially creating the table which defines the columns and setups the column headers. Another method loads the data from its passed in parameter an then sizes the table.
All is fine and I know the QTableWidget is being constructed and built but when I assign it to an instance in my main.py the table comes up blank. The only way I can get the table to display properly in my main.py is to assign the built table to an instance variable (table) from within it’s class.
Must be some misconception on my part. Any suggestions appreciated. Code provided is not complete and just to serve as explanation to my issue.
main.py:
from formations import formationsgrid
…
self.datagrid = formationsgrid(self.playflag, self.griddata).table (without the table grid is blank)
formations.py:
class formationsgrid(QTableWidget):
def init(self, formation_type, formation_data):
super().__init__()
self.type = formation_type
self.data = formation_data
self.table = None
self.create_table()
self.load_data()
def create_table(self):
self.table = QTableWidget()
...
def load_data(self):
self.table.setRowCount(len(self.data))
for rec in self.data:
...
if self.table.rowCount() > 6:
self.table.setFixedSize(834, 254)
elif self.table.rowCount() > 0:
...
else
self.table.setFixedSize(834, 98)