IMPORT_PATH has zero practical effect on qmlls
-
The title is a rant. I cannot get QML modules in a subdirectory to work at all.
The
MyModule_lib
is a CMake target which contains a perfectly working QML module (that prints "hello world" on construction), and in the main target, qmlls can find it if it's a direct subdirectory of the main project that matches its URI (./MyModule
). However, as soon as I move it into a nested directory (./modules/MyModule
), then nothing works at all.add_subdirectory(modules/MyModule) qt_policy(SET QTP0005 NEW) qt_add_qml_module( apphello_world URI hello_world IMPORT_PATH ${CMAKE_BINARY_DIR}/modules VERSION 1.0 DEPENDENCIES QtQuick IMPORTS TARGET MyModule_lib QML_FILES Main.qml)
qmlls will happily complain
Failed to import MyModule. Are your import paths set up properly? [import] Warnings occurred while importing module "MyModule": [import]
If someone can provide a minimal example where there's a QML module (
qt_add_library(XXX)
) nested within a directory to be properly consumed by the main executable target, with qmlls actually parsing its contents, I would greatly appreciate it. -
Turns out it wasn't me doing something wrong. It was a Qt bug: https://bugreports.qt.io/browse/QTCREATORBUG-31949
-