-
User Story
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
Why?
Cause - why, why, why this is needed?
- To avoid the manual handcrafting of main.cpp file because C++ is not familiar for Android developers nor UI Designers
- Change main.cpp file of each Qt Quick for Android Qt Quick QML project after exporting it from Qt Design Studio
Customer - who needs this?
- Qt Quick for Android users/customers two "groups"
- Android Developers - so that they do not touch the main.cpp as C++ is not familiar for them
- UI Designers - who prepare the 3D model to QMl project
Cruft - counter argument why this would not be needed?
- The handcrafted change is pretty small and only in one file
What?
Definition - what is this?
- Main.cpp changes to be done automatically by for example a Wizad. No manual modification needed from user.
- Current changes (what is need to be left there) are also described in
- We need to
- Remove QML Engine loading - cause when QQ4A (Qt Quick for Android) application is run the QtQuickView does the QML engine loading bit later
- Perhaps add variable to skip ^ parts in case of Qt Quick for Android app
A typical Qt Quick application's main.cpp appears like this
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() { QCoreApplication::exit(-1); },
Qt::QueuedConnection);
engine.loadFromModule("MyQtQuickProject", "Main");
return app.exec();
}
We don't need to create a QML Engine or load any QML handled by the Qt Quick View APIs. All that we need is:
#include <QGuiApplication>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
return app.exec();
}
So it could be something like Note! flag needs to be decided
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
#ifndef QT_ANDROID_QT_QUICK_FOR_ANDROID_STYLE_CPP
QQmlApplicationEngine engine;
__QObject::connect(
_ &engine,_
_ &QQmlApplicationEngine::objectCreationFailed,_
_ &app,_
_ []() { QCoreApplication::exit(-1); },_
_ _Qt::QueuedConnection);
_ _engine.loadFromModule("MyQtQuickProject", "Main");
#endif
return app.exec();
_ }_
**
Note the QT_ANDROID_NO_EXIT_CALL flag is not needed (Pixel devices do not even suffer from it) it is already set to on in QPA for QQ4A
Demarcation - what this is not?
- This does not cover removing the main.cpp completely from Qt Quick for Android app QML project.
Dependencies - what does this needs or who needs it?
- Is needed for QTBUG-130061
- Is needed to work with Qt 6.8 LTS to 6.11
- Needs TODO