forked from qt-creator/qt-creator
43 lines
1.3 KiB
C++
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();
|
|
}
|