Unable to create QML custom modules in cmake
-
I am trying to create a custom QML module in cmake and I keep getting
QQmlApplicationEngine failed to load component qrc:/QmlModules/main.qml:2:1: module "CustomItem" is not installed
I have create a file called
CustomPopup.qml
in$CWD/qml/CustomItem/
, in the sameCustomItem
folder, I have aqmldir
file with the following content:module CustomItem CustomPopup 1.0 ./CustomPopup.qml
And in
CMakeLists.txt
I added:list(APPEND QML_DIRS "${CMAKE_SOURCE_DIR}/qml") set(QML_IMPORT_PATH ${QML_DIRS} CACHE STRING "Custom modules" FORCE)
Also, in
main.cpp
, I added://... QQmlApplicationEngine engine; engine.addImportPath(":/qml"); //..
I still get the same error. Not sure what am I missing. Any help here would be appreciated.
Repository of this example is at https://github.com/akshaybabloo/QmlModules
-
I've noticed that running CMake doesn't refresh some stuff like pathes. In that case I advice you go to projects, in CMake category select Initial Configuration tab, and re-configure with initial parameters.
For the engine->addImportPath, don't specify a qrc:/ path if you didn't set a resource file, just specify the path to the main QML file without the :/ that is for qrc path.
-
@ankou29666 That did not work too. Also, I do have a qrc path