title: Problem in understanding connectSlotsByName() in pyqt?
body: <p>I couldn't understand the connectSlotsByName() method which is predominently used by pyuic4.. As far the class is single in a PyQt file it's ok since we can use self which will be associated with a single object throughout.. But when we try to use various classes from different files the problem and the need to use connectSlotsByName() arises.. Here's what i encountered which is weird..</p>
  
  <p>I created a stacked widget.. </p>
  
  <ul>
  <li><p>I placed my first widget on it.. It
  has a button called "Next >".</p></li>
  <li><p>On clicking next it hides the current
  widget and adds another widget which has the "click me" button..</p></li>
  </ul>
  
  <p>The problem here is the click event for "click me" button in second is not captured.. It's a minimal example that i can give for my original problem.. Please help me..</p>
  
  <p>This is file No.1..(which has the parent stacked widget and it's first page). On clicking next it adds the second page which has "clickme" button in file2..</p>
  
  <pre><code>from PyQt4 import QtCore, QtGui
  
  import file2
  
  class Ui_StackedWidget(QtGui.QStackedWidget):
  
      def __init__(self,parent=None):
  
          QtGui.QStackedWidget.__init__(self,parent)
  
          self.setObjectName("self")
          self.resize(484, 370)
          self.setWindowTitle(QtGui.QApplication.translate("self", "stacked widget", None, QtGui.QApplication.UnicodeUTF8))
  
          self.createWidget1()
  
      def createWidget1(self):
  
          self.page=QtGui.QWidget()
          self.page.setObjectName("widget1")
  
  
          self.pushButton=QtGui.QPushButton(self.page)        
          self.pushButton.setGeometry(QtCore.QRect(150, 230, 91, 31))
          self.pushButton.setText(QtGui.QApplication.translate("self", "Next &gt;", None, QtGui.QApplication.UnicodeUTF8))
  
  
          self.addWidget(self.page)
  
  
          QtCore.QMetaObject.connectSlotsByName(self.page)
  
            QtCore.QObject.connect(self.pushButton,QtCore.SIGNAL('clicked()'),self.showWidget2)
  
  
      def showWidget2(self):
  
          self.page.hide()
  
          obj=file2.widget2()
          obj.createWidget2(self)
  
  
  if __name__ == "__main__":
      import sys
      app = QtGui.QApplication(sys.argv)
      ui = Ui_StackedWidget()
      ui.show()
      sys.exit(app.exec_()) 
  </code></pre>
  
  <p>Here's file2</p>
  
  <pre><code>from PyQt4 import QtGui,QtCore
  
  class widget2():
  
      def createWidget2(self,parent):
  
          self.page = QtGui.QWidget()
          self.page.setObjectName("page")
  
          self.parent=parent
  
          self.groupBox = QtGui.QGroupBox(self.page)
          self.groupBox.setGeometry(QtCore.QRect(30, 20, 421, 311))
          self.groupBox.setObjectName("groupBox")
          self.groupBox.setTitle(QtGui.QApplication.translate("self", "TestGroupBox", None, QtGui.QApplication.UnicodeUTF8))
  
          self.pushButton = QtGui.QPushButton(self.groupBox)
          self.pushButton.setGeometry(QtCore.QRect(150, 120, 92, 28))
          self.pushButton.setObjectName("pushButton")
          self.pushButton.setText(QtGui.QApplication.translate("self", "Click Me", None, QtGui.QApplication.UnicodeUTF8))        
  
          self.parent.addWidget(self.page)
          self.parent.setCurrentWidget(self.page)
  
          QtCore.QMetaObject.connectSlotsByName(self.page)
  
          QtCore.QObject.connect(self.pushButton,QtCore.SIGNAL('clicked()'),self.printMessage)
  
  
      def printMessage(self):
  
          print("Hai")
  </code></pre>
  
  <p>Though in both the widgets(i mean pages) </p>
  
  <pre><code>QtCore.QMetaObject.connectSlotsByName(self.page)
  </code></pre>
  
  <p>the clicked signal in second dialog isn't getting processed. Thanks in advance.. Might be a beginner question..</p>