Important: Please read the Qt Code of Conduct -

QML module versions

  • Hi,

    Does anyone know how QML versions for modules actually work? The description from the documentation: "": :
    "A single module, in all versions, may only be provided in a single directory (and a single qmldir file). If multiple are provided, only the first in the search path will be used (regardless of whether other versions are provided by directories later in the search path)."

    When I tried my own example, as soon as the importer (with QML_IMPORT_TRACE defined) found an import path where the requested module existed, say with version 1.0 specified in the qmldir, then it gave a runtime error because my QML source file was trying to import version 2.0. It didn't go on to look at other paths that are in the import path list to see if the other module version existed there.

    Regarding the quote above: How can a single module be provided in a single directory with multiple versions? I thought the title of the file gives the name to the component, so you can only have one module file by that name.


  • Answering my own post here, but I found that you can have any name for the component qml file if you are using qmldir for an installed module. For example, component Button can be in xyz.qml if qmldir has the line "Button 1.0 xyz.qml". If there is no qmldir file, then the default convention is that component Button is in the file Button.qml.

Log in to reply