Solved How to quit qml safely?
-
Hello all:
In my application(arm device), the software can be reboot by user. There is my question: when the user click the reboot button, the onClick call the function in c++ to finish the job and reboot the device. but How to quit or exit qm safely?
I use QQmlApplicationEngine to load my qml files, below is the codeQQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/Main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url);
I read the help file, QQmlApplicationEngine has exit an quit signal
[signal] void QQmlEngine::quit()
This signal is emitted when the QML loaded by the engine would like to quit.
See also exit().How to quit engine?
-
Qt.quit() // or Qt.exit(someCode)
-
Qt.quit() // or Qt.exit(someCode)
-
@sierdzio tks a lot, I'll try it.