QQmlApplicationEngine::quit and QGuiApplication::quit
-
Hi,
I found an issue with the following code:
@
MyApplication::MyApplication(int& _argc, char** _argv):
QGuiApplication(_argc, _argv)
{
QQmlApplicationEngine *engine = new QQmlApplicationEngine(
QUrl("qrc:/my.qml"),
this
);connect( engine, &QQmlApplicationEngine :: quit, this, &QGuiApplication :: quit );
}
@"Qt.quit()":http://qt-project.org/doc/qt-5/qml-qtqml-qt.html#quit-method is called in my QML, and I checked QQmlApplicationEngine::quit was effectively emitted, but the application doesn't quit. I ended up with the following workaround:
@
connect(
engine, &QQmlApplicationEngine :: quit,
engine, &QQmlApplicationEngine :: deleteLater
);
connect(
engine, &QQmlApplicationEngine :: destroyed,
this, &QGuiApplication :: quit
);
@This version is working: QQmlApplicationEngine::quit schedules engine's deletion which exits the application. It seems QGuiApplication::quit doesn't work if the application has an alive QQmlApplicationEngine child. Did anybody experience something like that?
-
Hi,
What happens if you have something like
@
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine(QUrl("qrc:/my.qml"));
connect(engine, &QQmlApplicationEngine :: quit,
&app, &QGuiApplication :: quit);return app.exec();
}
@ -
I can't tell if it's a bug, untested scenario or expected behavior. You should have a look at the "bug report system":http://bugreports.qt-project.org to see if someone already wrote about that