Qt World Summit: Submit your Presentation

Locally Installed Modules

  • I want to use modules in my QtQuick application, but I have problems getting it to work.
    I make a new project, selects Qt Quick Application, and call it TestProject.

    Then I make a new directory in the same directory as the .pro file, calling it "MyComponents".
    Add new files "Comp1.qml" and "Comp2.qml" under the "MyComponents" directory.

    Following the example in http://doc.qt.io/qt-5/qtqml-modules-identifiedmodules.html , I make a new qmldir file in the "MyComponents" directory, with the following content:

    module TestProject.MyComponents 1.0
    Comp1 1.0 Comp1.qml
    Comp2 1.0 Comp2.qml

    I also set the QML_IMPORT_PATH in the pro file to the full path to the directory containing my TestProject folder.

    When I now set

    import TestProject.MyComponents 1.0

    in the main.qml file, it shows the import line fine without a red underline. But running the project always ends in

    qrc:/main.qml:4 module "TestProject.MyComponents" is not installed

    I am wondering what could be wrong, as I followed the instructions in the Qt Documentation.

Log in to reply