I am building a small application using pyQt5. Till now I've built a UI using QtCreator, converted that to a Python file using pyuic and now on the push of a button, it should dynamically populate the tabWidget's tabs with checkboxes having labels pulled from a string list. I can't seem to figure out the best way to go about this problem.
Till now I've done the following.
- Link the UI file with my main python code.
- Handle a button click to call a function to insert checkboxes.
class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
self.auth_select.clicked.connect(self.handle_auth)
self.show()
def populate_tabs(self):
self.tabWidget.addWidget(QtWidgets.QCheckBox())
I cannot seem to figure out how to dynamically insert the checkboxes into a certain tab. Let's say my tab name is main_tab
; I want to insert 5 checkboxes whose labels and ids come from 2 lists labels[]
and ids[]
.