1

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)
4
  • Did you re-run qmake after modifying the .pro file? Commented Dec 13, 2015 at 18:45
  • @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 installed Commented Dec 13, 2015 at 19:26
  • Would this help: github.com/jwintz/qchart.js/issues/3 Commented Dec 13, 2015 at 19:40
  • @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? Commented Dec 13, 2015 at 19:50

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.