Reputation: 321
I have one TabWidget a
nd want to add some tabs by clicking on a button. But it should work like
click Button "a" -> add Tab with title "a" and a special widget
click Button "b" -> add Tab with title "b" and a special widget
If I comment out the line with the slot of the button, all is working well. Also if I remove the parameter from the slot, it also gives no error message.
But with the code below I got:
" argument 1 has unexpected type 'NoneType' "
Is it wrong to add the parameter to the slot, like I did?
Thanks for your answers
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.ui= uic.loadUi('GUI/mainWindow.ui',self)
self.ui.tabWidget.setMovable(True)
self.ui.tabWidget.clear()
#Slots
self.ui.btn_lief.clicked.connect(self.addTab(Lieferschein(),'Lieferschein'))
def addTab(self,widget : 'QWidget',name : str):
idx = self.ui.tabWidget.currentIndex()+1
self.ui.tabWidget.insertTab(idx,widget,name)
self.ui.tabWidget.setCurrentIndex(idx)
Upvotes: 1
Views: 269