title: Using PyQt signals correctly
body: <p>A while ago I did some work in Qt for C++; now I'm working with PyQt.</p>
  
  <p>I have a subclass of QStackedWidget, and inside that a subclass of QWidget. In the QWidget I want to click a button that goes to the next page of the QStackedWidget. My (simplified) approach is as follows:</p>
  
  <pre><code>class Stacked(QtGui.QStackedWidget):
      def __init__(self, parent=None):
          QtGui.QStackedWidget.__init__(self, parent)
          self.widget1 = EventsPage()
          self.widget1.nextPage.connect(self.nextPage)
          self.widget2 = MyWidget()
          self.addWidget(self.widget1)
          self.addWidget(self.widget2)
  
      def nextPage(self):
          self.setCurrentIndex(self.currentIndex() + 1)
  
  
  class EventsPage(QtGui.QWidget):
      nextPage = QtCore.pyqtSignal()
  
      def __init__(self, parent=None):
          QtGui.QWidget.__init__(self, parent)
          self.continueButton = QtGui.QPushButton('Continue')
          self.continueButton.clicked.connect(self.nextPage)
  </code></pre>
  
  <p>So, basically, I'm connecting the continueButton <code>clicked</code> signal to the EventsPage <code>nextPage</code> signal, which I'm then connecting in Stacked to the <code>nextPage</code> method. I could just delve into the internals of EventsPage in Stacked and connect <code>self.widget1.continueButton.clicked</code>, but that seemed to completely defeat the purpose of signals and slots.</p>
  
  <p>So does this approach make sense, or is there a better way?</p>