forked from github_mirror/framelesshelper
Minor tweaks.
Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
d8e07b86c4
commit
083e5ec38c
|
@ -99,16 +99,21 @@ int main(int argc, char *argv[]) {
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
qmlRegisterType<FramelessQuickHelper>("wangwenx190.Utils", 1, 0,
|
qmlRegisterType<FramelessQuickHelper>("wangwenx190.Utils", 1, 0,
|
||||||
"FramelessHelper");
|
"FramelessHelper");
|
||||||
const QUrl url(QString::fromUtf8("qrc:///qml/main.qml"));
|
const QUrl mainQmlUrl(QString::fromUtf8("qrc:///qml/main.qml"));
|
||||||
QObject::connect(
|
const QMetaObject::Connection connection = QObject::connect(
|
||||||
&engine, &QQmlApplicationEngine::objectCreated, &application,
|
&engine, &QQmlApplicationEngine::objectCreated, &application,
|
||||||
[&url](QObject *obj, const QUrl &objUrl) {
|
[&mainQmlUrl, &connection](QObject *object, const QUrl &url) {
|
||||||
if (!obj && (url == objUrl)) {
|
if (url != mainQmlUrl) {
|
||||||
QCoreApplication::exit(-1);
|
return;
|
||||||
|
}
|
||||||
|
if (!object) {
|
||||||
|
QGuiApplication::exit(-1);
|
||||||
|
} else {
|
||||||
|
QObject::disconnect(connection);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
engine.load(url);
|
engine.load(mainQmlUrl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return QApplication::exec();
|
return QApplication::exec();
|
||||||
|
|
Loading…
Reference in New Issue