Signal QQmlEngine::quit() emitted, but no receivers connected to handle it quit(Signal QQmlEngine::quit() emitted, but no receivers connected to handle it quit)

1、问题描述

在QML中调用Qt.quit()但是程序没有退出

Keys.onPressed:
{
    switch(event.key)
    {
     case Qt.Key_M:
             Qt.quit();
             break;
    }
}

2、解决

//main.cpp
QApplication    app(argc, argv);
QQuickView      viewer;
QObject::connect(viewer.engine(), SIGNAL(quit()), &app, SLOT(quit()));
————————

< strong > 1. Problem description < / strong >

Calling Qt. in QML Quit() but the program did not exit

Keys.onPressed:
{
    switch(event.key)
    {
     case Qt.Key_M:
             Qt.quit();
             break;
    }
}

< strong > 2. Solve < / strong >

//main.cpp
QApplication    app(argc, argv);
QQuickView      viewer;
QObject::connect(viewer.engine(), SIGNAL(quit()), &app, SLOT(quit()));