Important: Please read the Qt Code of Conduct -

Cannot import QML module from resource file

  • I have the following directory layout in qrc file:



    import Components 1.0
    MenuButton 1.0 MenuButton.qml

    in main.cpp:


    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:

    import "components"

    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

  • Moderators

    @QJeroen said in Cannot import QML module from resource file:


    try the following (untested):


  • 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.

Log in to reply