Adding x number of extra tabs to the central widget is simple just by using this tabWidget.addTab()
:
self.tab = QtWidgets.QWidget()
for i in range(5):
self.tabWidget.addTab(QtWidgets.QWidget(), "tab" + str(i))
However, QTableWidget
doesn't seem to have such a feature and instead requires the name of the QWidget
every time. This means that I'd have to manually create each tab object for numbers in my range:
self.tab_1 = QtWidgets.QWidget()
self.tab_2 = QtWidgets.QWidget()
...
... before I can use them in the tableWidget
. Where the first line puts the table in tab_1
or the second line which duplicates the table in all tabs.
self.tableWidget = QtWidgets.QTableWidget(self.tab_1)
#self.tableWidget = QtWidgets.QTableWidget(self.tabWidget)
So I'd like some way of creating dynamic variables in my for loop (which I hear is a big no-no in Python) or some way of creating different reference-able tables in each of the tabs.