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()));

 

posted @ 2022-01-14 14:28  朱小勇  阅读(67)  评论(0编辑  收藏  举报