title: PyQt5 QML Signal to Python Slot?
body: <p>How can a python method/slot be connected to a QML signal? It looks like QtObject.connect() used to work in PyQt4 but it's <a href="http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html#old-style-signals-and-slots">no longer available in PyQt5</a>.</p>
  
  <pre><code>#Sample QML File (stack.qml)
  
  import QtQuick 2.0
  
  Rectangle {
      MouseArea {
          anchors.fill: parent
          onClicked: {
             // relay this to python
          }
      }
  }
  </code></pre>
  
  <p>--</p>
  
  <pre><code>#Sample Python File
  from PyQt5.QtCore import QUrl
  from PyQt5.QtGui import QGuiApplication
  from PyQt5.QtQuick import QQuickView
  
  if __name__ == '__main__':
      import os
      import sys
  
      app = QGuiApplication(sys.argv)
  
      view = QQuickView()
      view.setWidth(500)
      view.setHeight(500)
      view.setTitle('Hello PyQt')
      view.setResizeMode(QQuickView.SizeRootObjectToView)
      view.setSource(QUrl.fromLocalFile(os.path.join(os.path.dirname(__file__),'stack.qml')))
  
      def on_qml_mouse_clicked(mouse_event):
          print 'mouse clicked'
  
      view.show()
      qml_rectangle = view.rootObject()
  
      # this technique doesn't work #############################
      qml_rectangle.mousePressEvent.connect(on_qml_mouse_clicked)
  
      sys.exit(app.exec_())
  </code></pre>
  
  <p>Some of the PyQT examples pass an object into the QML context via "setContextProperty" and then relay QML events to slots on that object but that approach seems roundabout. Is there a better way?</p>