Minor tweaks.

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2020-05-13 21:33:15 +08:00
parent d8e07b86c4
commit 083e5ec38c
1 changed files with 11 additions and 6 deletions

View File

@ -99,16 +99,21 @@ int main(int argc, char *argv[]) {
QQmlApplicationEngine engine;
qmlRegisterType<FramelessQuickHelper>("wangwenx190.Utils", 1, 0,
"FramelessHelper");
const QUrl url(QString::fromUtf8("qrc:///qml/main.qml"));
QObject::connect(
const QUrl mainQmlUrl(QString::fromUtf8("qrc:///qml/main.qml"));
const QMetaObject::Connection connection = QObject::connect(
&engine, &QQmlApplicationEngine::objectCreated, &application,
[&url](QObject *obj, const QUrl &objUrl) {
if (!obj && (url == objUrl)) {
QCoreApplication::exit(-1);
[&mainQmlUrl, &connection](QObject *object, const QUrl &url) {
if (url != mainQmlUrl) {
return;
}
if (!object) {
QGuiApplication::exit(-1);
} else {
QObject::disconnect(connection);
}
},
Qt::QueuedConnection);
engine.load(url);
engine.load(mainQmlUrl);
#endif
return QApplication::exec();