Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. "QML module not found" but application runs
Forum Updated to NodeBB v4.3 + New Features

"QML module not found" but application runs

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
cmake
1 Posts 1 Posters 177 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ECEC
    wrote on 28 Dec 2023, 23:41 last edited by
    #1

    I've created a module in a subdirectory as follows:

    cmake_minimum_required(VERSION 3.16)
    
    project(superapp VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(Qt6 6.2 COMPONENTS Gui Quick Multimedia REQUIRED)
    
    qt_add_executable(appsuperapp
        main.cpp
    )
    
    qt_add_qml_module(appsuperapp
        URI Superapp
        VERSION 1.0
        RESOURCE_PREFIX /scythestudio.com/imports
        QML_FILES main.qml Pages/Page.qml
    )
    
    add_subdirectory(Test/MyComp)
    
    set_target_properties(appsuperapp PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    target_link_libraries(appsuperapp
        PRIVATE Qt6::Gui Qt6::Quick Qt6::Multimedia MyCompLibplugin)
    
    install(TARGETS appsuperapp
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
    
    qt_add_library(MyCompLib STATIC)
    
    set_target_properties(MyCompLib PROPERTIES AUTOMOC ON)
    target_link_libraries(MyCompLib PRIVATE Qt6::Quick)
    
    list(APPEND MODULE_QML_FILES
        MyButton.qml)
    
    qt_add_qml_module(MyCompLib
        URI MyComp
        VERSION 1.0
        QML_FILES
            ${MODULE_QML_FILES}
    )
    

    The application runs fine and I'm able to use import MyComp and use MyButton. However, QtCreator shows "QML module not found" next to the import and I'm not getting code completion or highlighting on MyButton:

    Screenshot 2023-12-28 234021.png

    Is this something I can safely ignore? Is there anything I can do to help QtCreator find the module?

    1 Reply Last reply
    0

    1/1

    28 Dec 2023, 23:41

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved