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

Javascript js files are not added into qmldir with qt_add_qml_module

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 6.2.2
    • None
    • CMake-3.22.1
      Qt-6.2.2
    • Windows

    Description

      I am creating a Qt6 QML module with qt_add_qml_module.

      qt_add_qml_module(SQUtils_Logger_Qml
       URI SQUtilsLogger.Qml
       VERSION 1.0
       SOURCES
         LoggerQml.cpp
       QML_FILES
         Log.js
         Logm.mjs
         LoggerQml.qml
       )

      But the generated qmldir contains only the information about the qml file: the js and mjs files are missing.

      module SQUtils.Logger.Qml
      linktarget SQUtils_Logger_Qmlplugin
      optional plugin SQUtils_Logger_Qmlplugin
      classname SQUtils_Logger_QmlPlugin
      typeinfo SQUtils_Logger_Qml.qmltypes
      prefer :/SQUtils/Logger/Qml/
      LoggerQml 1.0 LoggerQml.qml
      

      It is a problem because when I run "ninja all_qmllint", the compiler/linter complains that Log is not defined:

      // View.qml
      import SQUtils_Logger_Qml
      //import "qrc:/SQUtils/Logger/Qml/Log.js" as Log
      ApplicationWindow {
       Component.onCompleted: {
       Log.debug("QML main application complete")
       }
      }
      
      Warning: View.qml:120:13: Unqualified access
       Log.debug("QML main application complete)

      If I append "Log 1.0 Log.js" to the qmldir file, then the lint works.

      What I am doing wrong? Is this a bug? The qt documentation for qt_add_qml_module indeed quotes:

      QML_FILES lists the .qml, .js and .mjs files for the module. [...] 
      The files will also be used to populate type information in the generated qmldir file.

      Thank you for your help!

      Note: I can manage to run my code by uncommenting

      import "qrc:/SQUtils/Logger/Qml/Log.js" as Log

      but the lint still does not work.

      Attachments

        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
              pj_127 Pierre-Jean Arduin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes