Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in
read-only mode
.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
在qml如何捕获程序结束事件,然后清理内存。比如下面的代码,创建了一个线程,不知道在哪调用 清理线程函数j.join()。测试了QQmlApplicationEngine::quit不起作用
int main(int argc, char* argv[])
std::thread j([]() {
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(u"qrc:/untitled1/Main.qml"_qs);
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
[&](const QUrl& url) {
j.join();
QCoreApplication::exit(-1);
Qt::QueuedConnection
//以下代码捕获quit事件,但是永远不会被调用。
QObject::connect(
&engine,
&QQmlApplicationEngine::quit,
[&]() {
j.join();
Qt::QueuedConnection
engine.load(url);
return app.exec();