'Could not load qml included in qrc

I am setting up a simple project, which uses qml, qrc and conf files

But it always failed when run engine.load(url), saying that main.qml does not exist.

cmake file is like following, project structure shows in the screenshot, is there anyother place that I need to check?

cmake_minimum_required(VERSION 3.16)

project(Qml-Material-Imp VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt6 6.2 COMPONENTS Quick REQUIRED)

qt_add_executable(appQml-Material-Imp
    main.cpp    
    qml.qrc
)

set_target_properties(appQml-Material-Imp 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_compile_definitions(appQml-Material-Imp
    PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(appQml-Material-Imp
    PRIVATE Qt6::Quick)

enter image description here



Solution 1:[1]

I managed to make it with qmake instead and stayed with it

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cHiWa