Reputation: 143
I'm struggling with a custom QML module. The weird thing is that it works when I build and run perfectly fine on Linux (Ubuntu), but when I build and run on Windows, I get the following runtime error
Module jbQuick.Charts is not installed.
My root project directory contains a folder qml/jbQuick/Charts
which holds the qmldir
and QML files. The QML directory is added in the .pro
file:
QML_IMPORT_PATH = qml
The qml directory is added in the main.cpp file:
QQmlApplicationEngine engine;
engine.addImportPath(QStringLiteral("jbQuick/Charts"));
engine.addImportPath(QStringLiteral("qml"));
In the QML file where I want to use the custom module I state:
import jbQuick.Charts 1.0
Am I missing something? Is this a known issue?
Upvotes: 2
Views: 5517
Reputation: 4640
The most likely reason is that relative path is interpreted differently on your Windows system - possibly, because the current directory when you run your program is not your project root directory. Could you try absolute path, i.e:
engine.addImportPath("<your-project-root>/qml");
If that works, you can use GetModuleFileName to create a correct path relative to binary, at runtime.
Upvotes: 3