[Interest] qt_add_qml_module() RESOURCES vs qt_add_resources()

ekke ekke at ekkes-corner.org
Tue Feb 13 13:41:03 CET 2024


have ported all my apps from 5.15 to 6.6, now on my way from QMake to CMake

noticed a problem if adding images etc to qt_add_qml_module() RESOURCES:

set(CMAKE_AUTORCC ON)
...
qt_add_executable(${MY_APP}
     cpp/main.cpp
)

# module not re-used, executed at app-start

qt_add_qml_module(${MY_APP}
     URI Main_Module
     QML_FILES
         ${my_qml_files}
         ${my_js_files}
     SOURCES
         ${my_cpp_files}
     RESOURCES
         ${my_image_files}
         ${my_data-assets_files}
)

QML and SOURCES ok, but RESOURCES not available, per ex. 
qrc:/images/add.png fails

Adding the RESOURCES via qt_add_resources() all is working:

qt_add_qml_module(${MY_APP}
     URI Main_Module
     QML_FILES
         ${my_qml_files}
         ${my_js_files}
     SOURCES
         ${my_cpp_files}
)
qt_add_resources(${MY_APP}
     "images"
     PREFIX "/"
     FILES
         ${my_image_files}
)
qt_add_resources(${MY_APP}
     "data-assets"
     PREFIX "/"
     FILES
         ${my_data-assets_files}
)

Wanted to place the RESOURCES into qt_add_qml_module(), because they're 
used by QML and SOURCES from the module.

Am I doing something wrong or should I open an issue ?

thx ekke



More information about the Interest mailing list