Jan Roorda
Jan Roorda

Reputation: 143

QtQuick: Module is not installed

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

Answers (2)

Vladimir Prus
Vladimir Prus

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

Akash Agarwal
Akash Agarwal

Reputation: 2520

Copying the qml folder to your build folder worked for me.

Upvotes: 1

Related Questions