Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-30724

Qt Creator doesn't understand QML module added with CMake

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 13.0.0
    • Quick / QML Support
    • None
    • Ubuntu 22.04, CMake 3.22.1, Qt SDK 6.5.5
    • Linux/X11

    Description

      In my `CMakeLists.txt` I have:

       

          qt_add_qml_module(MyModule
              URI MyModule
              VERSION 1.0
              RESOURCE_PREFIX /
              QML_FILES ${QML_SOURCE_FILES}
          ) 
      

       

      I have configured some of the QML-files as SINGLETONS:

       

      set_source_files_properties(MySingleton.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE) 
      

       

      Seems that these singletons won't work without explicitly importing my `MyModule` in Main.qml:

       

      import QtCore
      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Controls.Universal 2.15
      import QtQuick.Dialogs
      import QtQuick.Effects
      
      import MyModule // This is needed to make singletons work. See the auto-generated qmldir-files. 
      

       

      This works fine, but `Qt Creator` doesn't understand the import line (it says that QML module is not found):

       

      However, another topic would be that why singletons require this import in the first place. 

       

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            juzzlin Jussi Lind
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes