title: Edit tab name from child class
body: <p>I am trying to have a function change the text listed on a tab, but I am having trouble figuring out how to properly reference the tab.</p>
  
  <p>The below code works, but does nothing since the one line is commented out. I know the issue is with the "self" in that line (un-commenting the line causes the error when the button is clicked), but I do not know what is supposed to go there to make it work.  I am guessing that my issue is with the tab being created by a different class, but I want to be able to open multiple tabs with the same widgets in each one (as this code does).  Will I have to restructure the code to make this work?</p>
  
  <pre><code>from PyQt5.QtWidgets import (QMainWindow, QApplication, QAction, qApp,
      QPushButton, QWidget, QMenu, QVBoxLayout, QTabWidget, QLineEdit,
      QLabel, QHBoxLayout)
  import sys
  
  class MainWin(QMainWindow):
  
      def __init__(self):
          super().__init__()
  
          self.initUI()
  
      def initUI(self):
  
          exitAct = QAction('&amp;Exit', self)
          exitAct.triggered.connect(qApp.quit)
  
          newAct = QAction('&amp;New Tab', self)
          newAct.triggered.connect(self.newTab)
  
          menubar = self.menuBar()
          fileMenu = menubar.addMenu('&amp;File')
  
          fileMenu.addAction(newAct)
          fileMenu.addAction(exitAct)
  
          self.layout = QVBoxLayout()
  
          self.tabbed = QTabWidget(self)
          self.layout.addWidget(self.tabbed)
          self.setCentralWidget(self.tabbed)
  
          self.show()
  
      def newTab(self):
          self.tab1 = tabbedFrame(self.tabbed)
          self.tabbed.addTab(self.tab1, self.tab1.tabName)
  
  
  class tabbedFrame(QWidget):
      def __init__(self, parent):
          super(tabbedFrame, self).__init__(parent)
          layout = QVBoxLayout()
          self.updateButton = QPushButton("Update")
          self.updateButton.clicked.connect(self.updateTab)
          layout.addWidget(QLabel("Tab Name"))
          self.nameLineEdit = QLineEdit("New Tab")
          self.tabName = self.nameLineEdit.text()
          layout.addWidget(self.nameLineEdit)
          layout.addWidget(self.updateButton)
          self.setLayout(layout)
  
      def updateTab(self):
          tabindex = win.tabbed.currentIndex
          #win.tabbed.setTabText(self, tabindex, self.tabName)
  
  
  if __name__ == '__main__':
      app = QApplication(sys.argv)
      win = MainWin()
      sys.exit(app.exec_())
  </code></pre>