Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Design Tooling
  3. Qt Design Studio
  4. QML Module Not Found
Forum Update on Monday, May 27th 2025

QML Module Not Found

Scheduled Pinned Locked Moved Solved Qt Design Studio
2 Posts 1 Posters 1.6k 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.
  • C Offline
    C Offline
    c0ntrarian
    wrote on last edited by
    #1

    Hello, I have been scratching my head on this problem for 3 days.

    How do I correctly import a custom QML Module into QT Designer. My code compiles fine and works in QT Creator, but when I bring it to QT Design Studio, I cannot seem to get QT Design Studio to be happy with custom modules.

    6f35751d-2a7b-4d36-856c-83ca0bd88c1d-image.png

    CMake:

    cmake_minimum_required(VERSION 3.21.1)
    
    option(LINK_INSIGHT "Link Qt Insight Tracker library" ON)
    option(BUILD_QDS_COMPONENTS "Build design studio components" ON)
    
    project(GEO_OSApp LANGUAGES CXX)
    
    set(CMAKE_AUTOMOC ON)
    
    find_package(Qt6 6.2 REQUIRED COMPONENTS Core Gui Qml Quick SerialPort)
    
    
    if (Qt6_VERSION VERSION_GREATER_EQUAL 6.3)
        qt_standard_project_setup()
    endif()
    
    qt_add_executable(GEO_OSApp src/main.cpp
        src/serial.h src/serial.cpp
        src/admin.h src/admin.cpp
        src/radialbar.h src/radialbar.cpp
        src/data.h src/data.cpp
    )
    
    qt_add_resources(GEO_OSApp "configuration"
        PREFIX "/"
        FILES
            qtquickcontrols2.conf
    )
    
    target_link_libraries(GEO_OSApp PRIVATE
        Qt6::Core
        Qt6::Gui
        Qt6::Qml
        Qt6::Quick
        Qt6::SerialPort
    )
    
    set(QT_QML_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/qml)
    set(QML_IMPORT_PATH ${QT_QML_OUTPUT_DIRECTORY}
        CACHE STRING "Import paths for Qt Creator's code model"
        FORCE
    )
    
    if (BUILD_QDS_COMPONENTS)
        include(${CMAKE_CURRENT_SOURCE_DIR}/qmlcomponents)
    endif()
    
    include(${CMAKE_CURRENT_SOURCE_DIR}/qmlmodules)
    
    if (LINK_INSIGHT)
        include(${CMAKE_CURRENT_SOURCE_DIR}/insight)
    endif ()
    
    include(GNUInstallDirs)
    install(TARGETS GEO_OSApp
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    )
    
    # make IDEs aware of the QML import path
    set(QML_IMPORT_PATH ${PROJECT_BINARY_DIR}/qml CACHE PATH
        "Path to the custom QML components defined by the project")
    

    main.cpp:

    int main(int argc, char *argv[])
    {
        set_qt_environment();
    
        QGuiApplication app(argc, argv);
    
        // Register classes with QML
        qmlRegisterType<Serial>("Serial", 1, 0, "Serial");
        qmlRegisterType<Admin>("Admin", 1, 0, "Admin");
        qmlRegisterType<RadialBar>("CustomControls", 1, 0, "RadialBar");
    .......
    
    

    qmldir:

    Module GEO_OS
    singleton Constants 1.0 Constants.qml
    EventListSimulator 1.0 EventListSimulator.qml
    EventListModel 1.0 EventListModel.qml
    DirectoryFontLoader 1.0 DirectoryFontLoader.qml
    CustomComponents 1.0 RadialBar.qml
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      c0ntrarian
      wrote on last edited by
      #2

      Solved by updating importPaths in .qmlproject and creating a NEW qmldir file in the actual folder (PROJECT_NAME/imports/MODULE_NAME/qmldir) with the following properties:

      module RadialBar
      RadialBar 1.0 RadialBar.qml
      

      Move the plugin code into PROJECT_NAME/imports/MODULE_NAME/ and call it using import RadialBar 1.0.

      Then restart Qt Design Studio.

      1 Reply Last reply
      0
      • C c0ntrarian has marked this topic as solved on

      • Login

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