Ivan Fateev
Ivan Fateev

Reputation: 1061

Install QChart.js qml module: module not found

i'm struggling with using a qml module: https://github.com/jwintz/qchart.js.

According to documentation

But QtCreator shows error: module not found

enter image description here

Update

After clean build and rerun of qmake, error editor disappeared, but in runtime I'm getting:

qrc:/analyzer.qml:7 module "jbQuick.Charts" is not installed

Update As mentioned in comments, I've added import paths to main.cpp:

engine.addImportPath(QStringLiteral("qmlModules"));

But the error still exists.

Disabling the shadow build solves the problem. Looks like I missed something in deploy step (copy of qml module's files)

CONFIG += c++11 qml_debug
TEMPLATE = app

QT += qml quick widgets webkit webkitwidgets


HEADERS += VKApi.h \
    VKResponse.h \
    VKRequest.h \
    VKRequestManager.h \
    VKProfileAnalyzer.h \
    VKGroup.h \
    VKDayStats.h

SOURCES += main.cpp \
            VKApi.cpp \
    VKResponse.cpp \
    VKRequest.cpp \
    VKRequestManager.cpp \
    VKProfileAnalyzer.cpp \
    VKGroup.cpp \
    VKDayStats.cpp


RESOURCES += qml.qrc

QML_IMPORT_TRACE = 1

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH += ./qmlModules
QML2_IMPORT_PATH += ./qmlModules

# Default rules for deployment.
include(deployment.pri)

Upvotes: 1

Views: 2117

Answers (1)

Ivan Fateev
Ivan Fateev

Reputation: 1061

Thank you for all your comments.

Summarizing all steps required to install QML Module locally (in project dir):

  1. Make sure var QML_IMPORT_PATHS is defined in a *.pro

QML_IMPORT_PATH += ./qmlModules

  1. Add import paths in main.cpp (for qmake projects)
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);


    QQmlApplicationEngine engine;
    engine.addImportPath(QStringLiteral("qmlModules"));
    engine.load(QUrl(QStringLiteral("qrc:/analyzer.qml")));

    return app.exec();
}
  1. Make sure plugin's files are correctly deployed. I've used solution from here
copydata.commands = $(COPY_DIR) $$PWD/qmlModules $$OUT_PWD
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_EXTRA_TARGETS += first copydata

Upvotes: 1

Related Questions