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

Type compiler unable to use components from imported modules

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • Some future release
    • 6.5.8, 6.6.3
    • QML: Compiler
    • None
    • All

      The QML Type Compiler indicates "Warnings occurred while importing module" and the when using the QML Component in question, it appears to not be found.

      To replicate the issue:

      1. Create 2 or more QML modules with qt_add_qml_module. Each module must have a QML file
      2. Import one module, let's call it second module, into the other module, let's call it main module
      3. Import and instantiate a QML component of the second module from the main module.
      4. ENABLE_TYPE_COMPILER on both modules

      Example code is attached. Important excerpts here:

      // Second module's CMakeLists.txt

      qt_add_qml_module(${PROJECT_NAME}
          URI SharedModule
          VERSION 1.0
          RESOURCE_PREFIX /qt/qml/
          QML_FILES
          "SharedModule.qml"
          ENABLE_TYPE_COMPILER
      )

      // Second module's .qml file

      Rectangle {
          color: "#234567"
      }

      // First module's CMakeLists.txt

      qt_add_qml_module(${PROJECT_NAME}
          URI Experiments
          VERSION 1.0
          RESOURCE_PREFIX /qt/qml/
          IMPORTS
          SharedModule
          QML_FILES
          "main.qml"
          ENABLE_TYPE_COMPILER
      )

      // First module's .qml file

      import SharedModule

      SharedModule {
          width: 400
          height: 200
      }

      Note:
      This fails in the same way regardless of whether the modules are imported Dynamically or Statically.

        1. image-2024-08-05-13-51-12-459.png
          102 kB
          Stefan Bauer
        2. QMLTC importing C++modules.tar.gz
          2 kB
          Javier Cordero
        3. QMLTC importing C++ smallest module.tar.gz
          1 kB
          Javier Cordero
        4. QMLTC importing C++ smallest module qmllint-warning-free.zip
          8 kB
          Sami Shalayel
        5. QMLTC importing other QML modules.tar.gz
          2 kB
          Javier Cordero
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qtqmlteam Qt Qml Team User
            javier.cordero Javier Cordero
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes