Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Cannot import QML module from resource file
QJeroen last edited by QJeroen
I have the following directory layout in qrc file:
import Components 1.0 MenuButton 1.0 MenuButton.qml
Now when I import in Main.qml it doesn't work from resource file, but it does work when using local file system:
import Components 1.0
If I change the code this way:
Than it also works from resource file. But I don't understand why I cannot load it as a module when it is placed in a resource file. It works on local file system but not in resource file. I thought it was the import path, but that seems to be correct IMHO.
Does anybody know how to import modules from a resource file? I'm using Qt 5.10.1
try the following (untested):
engine.addImportPath(QStringLiteral(":/")); //or engine.addImportPath(QStringLiteral("qrc:/"));
QJeroen last edited by
The problem was that the "components" subdirectory is written in lowercase, but module import uses Components. They need to match (import statement, module line in qmldir and the directory name).
The ModuleIdentifier is the (dotted URI notation) identifier for the module, which must match the module's install path. And the install path is relative to an import path.