Uploaded image for project: 'Qt Design Studio'
  1. Qt Design Studio
  2. QDS-15729

Template to export Qt Quick for Android Cmake project

XMLWordPrintable

    • Icon: User Story User Story
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • None
    • CMake exporter
    • Android

      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?

      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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            rampe Rami Potinkara
            rampe Rami Potinkara
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes