title: PyQt5 QTabWidget: How to switch between tabs contained in classes and in the same window?
body: <p>I would like to switch tabs contained in their own classes when pushing a button (next/prior tabs). However, I cannot seem to do it. If I use self.tabs.show() I open a new window. However, I just want it to switch in the same window. Can you help me? Example code below.</p>
  
  <pre><code>from PyQt5.QtWidgets import QPushButton, QTabWidget, QApplication, QDialog, QVBoxLayout, QWidget
  import sys
  
  class Tab(QDialog):
      def __init__(self):
          super().__init__()
  
          vbox = QVBoxLayout()
          self.tabWidget = QTabWidget()
          self.tabWidget.addTab(TabContact(), "Contact Details")
          self.tabWidget.addTab(TabPeronsalDetails(), "Personal Details")
          vbox.addWidget(self.tabWidget)
          self.setLayout(vbox)
  
  
  class TabContact(QWidget):
      def __init__(self):
          super().__init__()
          pushButton = QPushButton("Go to next")
          pushButton.clicked.connect(self.nextTab)
  
          vbox = QVBoxLayout()
          vbox.addWidget(pushButton)
  
          self.setLayout(vbox)
  
      def nextTab(self):
          self.tabs = Tab()
          self.tabs.tabWidget.setCurrentIndex(0)
  
  
  class TabPeronsalDetails(QWidget):
      def __init__(self):
          super().__init__()
  
          pushButton_2 = QPushButton("Go to prior")
          pushButton_2.clicked.connect(self.priorTab)
  
          vbox = QVBoxLayout()
          vbox.addWidget(pushButton_2)
  
          self.setLayout(vbox)
  
      def priorTab(self):
          self.tabs = Tab()
          self.tabs.tabWidget.setCurrentIndex(0)
  
  
  if __name__ == "__main__":
      app = QApplication(sys.argv)
      tabdialog = Tab()
      tabdialog.show()
      app.exec()
  </code></pre>