Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-122986

Document recommended project structure for projects that have a QML module used by two or more executables

    XMLWordPrintable

Details

    Description

      The attached project has a QML module that will be used by both the app, and, eventually, integration tests (they will test the UI). The structure looks like this:

      .
      ├── CMakeLists.txt
      ├── Scheduler
      │   ├── CMakeLists.txt
      │   ├── MainScreen.qml
      │   ├── schedulerglobal.h
      │   ├── task.cpp
      │   └── task.h
      ├── SchedulerApp
      │   ├── CMakeLists.txt
      │   ├── fonts
      │   │   └── fontello
      │   │       ├── config.json
      │   │       ├── fontello.ttf
      │   │       └── LICENSE.txt
      │   ├── main.cpp
      │   └── Main.qml
      └── tests
          ├── auto
          │   ├── CMakeLists.txt
          │   └── unit
          │       ├── CMakeLists.txt
          │       └── tst_models.cpp
          └── CMakeLists.txt
      

      When running SchedulerApp on Kubuntu 22.04, I get this error:

      16:36:41: Starting /home/mitch/dev/temp/scheduler-Desktop_Qt_6_6_0_GCC_64bit-Debug/SchedulerApp/schedulerapp...
      QML debugging is enabled. Only use this in a safe environment.
      QQmlApplicationEngine failed to load component
      qrc:/qt/qml/SchedulerApp/Main.qml:3:1: module "Scheduler" is not installed
      16:36:41: /home/mitch/dev/temp/scheduler-Desktop_Qt_6_6_0_GCC_64bit-Debug/SchedulerApp/schedulerapp exited with code 255
      

      Apparently this is because the recommended structure in this scenario is to have the Scheduler module (project) be a child of the SchedularApp, rather than have them as siblings. This is what the Wearable example does:

      https://code.qt.io/cgit/qt/qtdeclarative.git/tree/examples/quickcontrols/wearable/CMakeLists.txt

      Fabian mentioned that it will work if I:

      • Install the Scheduler module. That's fine for deployment but it shouldn't be necessary for the development phase, in my opinion: QTBUG-122987.
      • Link against the backing library of the Scheduler module, because then it should be found via the qrc path (on Linux).

      However, https://doc.qt.io/qt-6/cmake-build-reusable-qml-module.html doesn't explicitly say that the "example"/"mylib" structure is the only supported structure. If this is the case, it should be clearly documented.

      If it's not the only supported structure (which I argue it shouldn't be), it should also explain how to handle the case of many executables that use a QML module, as the example project structure it uses is very simplistic.

      Attachments

        1. Screenshot 2024-04-21 at 09.45.19.png
          62 kB
          Mitch Curtis
        2. scheduler.zip
          10 kB
          Mitch Curtis

        Issue Links

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

          Activity

            People

              qtqmlteam Qt Qml Team User
              mitch_curtis Mitch Curtis
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes