There is a class MainWindow, which has a bar with tabs. One of the tabs create FactorsTab class, located in FactorsTabWidget.py file.
at startup crashes:
line 13, in init self.table = QtGui.QStandardItemModel(parent=self.frame_factors) AttributeError: 'NoneType' object has no attribute 'QStandardItemModel'
line 13 in file FactorsTabWidget.py: self.table = > QtGui.QStandardItemModel(parent=self.frame_factors)
How to generate the contents of a tab from another class?
file main.py
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent)
factors_tab = FactorsTabWidget.FactorsTab()
self.tabs = QtWidgets.QTabWidget()
self.tabs.addTab(factors_tab, "Factors")
file FactorsTabWidget.py
class FactorsTab(QtWidgets.QWidget):
def __init__(self):
QtWidgets.QWidget.__init__(self, parent=None)
self.frame_factors = QtWidgets.QTableView()
self.table = QtGui.QStandardItemModel(parent=self.frame_factors)
self.lst1 = ['Дискета', 'Бумага для принтера', 'Барабан для принтера']
self.lst2 = ["10", "3", "10452048"]
for row in range(0, 3):
item1 = QtGui.QStandardItem(self.lst1[row])
item2 = QtGui.QStandardItem(self.lst2[row])
self.table.appendRow([item1, item2])
self.table.setHorizontalHeaderLabels(['Factor Name', 'Кол-во'])
self.frame_factors.setModel(self.table)
QtGui == None
, maybe you setQtGui = None
orQtGui = something
in some place.