Files
qt-creator/share/qtcreator/templates/wizards/projects/qtquickapplication/main.cpp
Eike Ziller e2baa116ca Merge remote-tracking branch 'origin/4.5'
Change-Id: I86852d289c22210a0439e8e297819dc7276a96de
2017-11-29 09:56:22 +01:00

43 lines
1.3 KiB
C++

%{Cpp:LicenseTemplate}\
%{JS: QtSupport.qtIncludes([], ["QtGui/QGuiApplication", "QtQml/QQmlApplicationEngine"])}
int main(int argc, char *argv[])
{
@if %{SetQPAPhysicalSize}
qputenv("QT_QPA_EGLFS_PHYSICAL_WIDTH", QByteArray("213"));
qputenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT", QByteArray("120"));
@endif
@if %{UseVirtualKeyboard}
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
@endif
#if defined(Q_OS_WIN)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl mainQml(QStringLiteral("qrc:/main.qml"));
// Catch the objectCreated signal, so that we can determine if the root component was loaded
// successfully. If not, then the object created from it will be null. The root component may
// get loaded asynchronously.
const QMetaObject::Connection connection = QObject::connect(
&engine, &QQmlApplicationEngine::objectCreated,
&app, [&](QObject *object, const QUrl &url) {
if (url != mainQml)
return;
if (!object)
app.exit(-1);
else
QObject::disconnect(connection);
}, Qt::QueuedConnection);
engine.load(mainQml);
return app.exec();
}