简体   繁体   中英

Add dynamic number of QLabel and QLineEdit inside a tab widget

I want to make a button that when press, it will generate a label and line edit. I tried using this code but the label will goes to the mainwindow. I want to put that on tabwidget page I create on QT designer.

    def predict_student(self):
        self.label = QLabel('This is label', self)
        self.label.show()

I just solved my problem by creating a form layout inside the page and adding the label on that specific layout.

def predict_student(self):
        self.label1 = QLabel('This is label', self)
        self.formLayout.addWidget(self.label1)
        self.label1.show()
 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM