title: PyQt proper use of emit() and pyqtSignal()
body: <p>I am reading through some documentation on PyQt5 to come up with a simple signal-slot mechanism. I have come to a halt due to a design consideration.</p>
  
  <p>Consider the following code:</p>
  
  <pre><code>import sys
  from PyQt5.QtCore import (Qt, pyqtSignal)
  from PyQt5.QtWidgets import (QWidget, QLCDNumber, QSlider,
      QVBoxLayout, QApplication)
  
  
  class Example(QWidget):
  
      def __init__(self):
          super().__init__()
  
          self.initUI()
  
      def printLabel(self, str):
          print(str)
  
      def logLabel(self, str):
          '''log to a file'''
          pass
  
      def initUI(self):
  
          lcd = QLCDNumber(self)
          sld = QSlider(Qt.Horizontal, self)
  
          vbox = QVBoxLayout()
          vbox.addWidget(lcd)
          vbox.addWidget(sld)
  
          self.setLayout(vbox)
  
          #redundant connections
          sld.valueChanged.connect(lcd.display)
          sld.valueChanged.connect(self.printLabel)
          sld.valueChanged.connect(self.logLabel)
  
          self.setGeometry(300, 300, 250, 150)
          self.setWindowTitle('Signal &amp; slot')
          self.show()
  
  
  if __name__ == '__main__':
  
      app = QApplication(sys.argv)
      ex = Example()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>To track the changes made to the slider, I simply print and log the changes made. What I do not like about the code is that I am required to call the <code>sld.valueChanged</code> slot thrice to send the same information to 3 different slots. </p>
  
  <p>Is it possible to create my own <code>pyqtSignal</code> that sends an integer to a single slot function. And in turn have the slot function emit the changes that need to be made? </p>
  
  <ul>
  <li>Maybe I don't fully understand the purpose of <code>emit()</code> because there are no good examples of it's purpose in the <a href="http://pyqt.sourceforge.net/Docs/PyQt5/signals_slots.html#connecting-disconnecting-and-emitting-signals" rel="noreferrer">PyQt Signal-Slot docs</a>. All we're given is an example of how to implement an <code>emit</code> with no parameters.</li>
  </ul>
  
  <p>What I would like to do is create a function that handles the emit function. Consider the following:</p>
  
  <pre><code>import sys
  from PyQt5.QtCore import (Qt, pyqtSignal)
  from PyQt5.QtWidgets import (QWidget, QLCDNumber, QSlider,
      QVBoxLayout, QApplication)
  
  
  class Example(QWidget):
  
      def __init__(self):
          super().__init__()
  
          #create signal
          self.val_Changed = pyqtSignal(int, name='valChanged')
  
          self.initUI()
  
      def initUI(self):
  
          lcd = QLCDNumber(self)
          sld = QSlider(Qt.Horizontal, self)
  
          vbox = QVBoxLayout()
          vbox.addWidget(lcd)
          vbox.addWidget(sld)
  
          self.setLayout(vbox)
  
          sld.val_Changed.connect(self.handle_LCD)
          self.val_Changed.emit()
  
          self.setGeometry(300, 300, 250, 150)
          self.setWindowTitle('Signal &amp; slot')
          self.show()
  
      def handle_LCD(self, text):
          '''log'''
          print(text)
          '''connect val_Changed to lcd.display'''
  
  if __name__ == '__main__':
  
      app = QApplication(sys.argv)
      ex = Example()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>There are obviously some serious design flaws here. I cannot wrap my head around the order of function calls. And I am not implementing <code>pyqtSignal</code>  correctly. I do however believe that correctly stating the following 3 points will help me produce a proper app:</p>
  
  <ol>
  <li>For a predefined signal: send the signal to the slot function. Slot can be reimplemented to use the signal values.</li>
  <li>Produce <code>pyqtSignal</code> object with some parameters. It is not yet clear what the purpose of these parameters are and how they differ from 'emit' parameters.</li>
  <li><code>emit</code> can be reimplemented to send specific signal values to the slot function. It is also not yet clear why I would need to send different values from previously existing signal methods.</li>
  </ol>
  
  <p>Feel free to completely alter the code for what I am trying to do because I have not yet figured out if its in the realm of good style.</p>