title: How to close Pyqt5 program from QML?
body: <p>I started a project in Qt Creator initially with a C++ backend, but then switched it to use PyQt5. I have a main.qml, where when I press a button called <code>Exit</code>, I call <code>Qt.quit()</code>.</p>
  
  <p>However, I get a <code>General Message</code> stating: <code>Signal QQmlEngine::quit() emitted, but no receivers connected to handle it.</code></p>
  
  <p>My question is, how do I receive this signal and handle it?</p>
  
  <p>Code:</p>
  
  <p>main.py:</p>
  
  <pre><code>import sys
  import PyQt5
  
  from PyQt5 import QtCore
  from PyQt5 import QtGui
  from PyQt5 import QtQml
  from PyQt5.QtCore import QObject pyqtSignal
  
  
  class DestinyManager,(QtGui.QGuiApplication):
      """the app self"""
      def __init__(self, argv):
          super(DestinyManager, self).__init__(argv)
  
      # Define a new signal called 'trigger' that has no arguments.
      trigger = pyqtSignal()
  
      def connect_and_emit_trigger(self):
          # Connect the trigger signal to a slot.
          self.trigger.connect(self.handle_trigger)
          self.menuItem_Exit.clicked.connect(self.close)
          # Emit the signal.
          self.trigger.emit()
  
      def handle_trigger(self):
          # Show that the slot has been called.
          print("trigger signal received")
  
  def main(argv):
      app = DestinyManager(sys.argv)
      engine = QtQml.QQmlEngine(app)
      component = QtQml.QQmlComponent(engine)
      component.loadUrl(QtCore.QUrl("exit.qml"))
      topLevel = component.create()
      if topLevel is not None:
          topLevel.show()
      else:
          for err in component.errors():
              print(err.toString())
      app.exec()
  
  if __name__ == '__main__':
      QObject,main(sys.argv)
  </code></pre>
  
  <p>Exit.qml:</p>
  
  <pre><code>import QtQuick 2.4
  import QtQuick.Controls 1.3
  import QtQuick.Window 2.2
  
  Window {
  
      Button {
      id: btn_Exit
      text: "Exit"
  
      onClicked: Qt.quit();
  
      }
  }
  </code></pre>