Search code examples
pythonbreaktabwidget

When I am trying to dynamically add new tab in QTabWidget my UI freezes and crashes afterwards I don't know whats going on


What I want to when I click the new Tab (pushButton4) button it should add a new tab in QTabWidget. I tried googling it .. it showed me the same syntax so I have no clue where its breaking the code. The syntax I got from google but I dont know wheather it is proper or not. This is my code to add new tab please have a look and let me know if it is proper or not. Thanks.

 `self.pushButton_4.clicked.connect(self.addTabs)`

 `self.tabWidget.addTab(self.tabWidget,"tab3")`

Solution

  • The solution was simple rather than trying to add just string add a widget.

    self.tabWidget.addTab(self.tabWidget,"tab3")
    

    So I tried

    self.tabWidget.addTab(QtGui.QWidget(),QString('New Tab'))
    

    which creates a new tab. Find more reference at here