1
votes

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

According to documentation

  • I've placed files in $PROJECT/qmlModules/jbQuick/Charts/*.
  • Added QML_IMPORT_PATH to .pro file.

    QML_IMPORT_PATH += ./qmlModules

  • Now I'm trying to import jbQuick.Charts 1.0,

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)
1
Did you re-run qmake after modifying the .pro file?MrEricSir
@MrEricSir after clean build and rerunning of qmake, qtcreator doesn't show error anymore in editor, but in runtime I'm getting module "jbQuick.Charts" is not installedIvan Fateev
@juzzlin yeah, thx. Looks like similar issue, but after adding import paths: engine.addImportPath(QStringLiteral("qmlModules")); engine.addImportPath(QStringLiteral("jbQuick/Charts")); I'm still getting the error. Disabling the shadow build solves the issue. But looks like I'm missing something with deploy step. Should I add something to deploy the module?Ivan Fateev

1 Answers

1
votes

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