首页 文章

安装QChart.js qml模块:找不到模块

提问于
浏览
1

我正在努力使用qml模块:https://github.com/jwintz/qchart.js .

根据documentation

  • 我把文件放在$ PROJECT / qmlModules / jbQuick / Charts / *中 .

  • 已将.2818432_添加到.pro文件中 .

QML_IMPORT_PATH = ./qmlModules

  • 现在我正在尝试导入jbQuick.Charts 1.0,

但QtCreator显示错误:找不到模块

enter image description here

Update

在干净的构建和重新运行qmake之后,错误编辑器消失了,但在运行时我得到:

qrc:/anzerzer.qml:7模块“jbQuick.Charts”未安装

Update 正如评论中所提到的,我已经为main.cpp添加了导入路径:

engine.addImportPath(QStringLiteral(“qmlModules”));

但错误仍然存在 .

禁用阴影构建可以解决问题 . 看起来我错过了部署步骤(qml模块文件的副本)

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 回答

  • 1

    感谢您的所有意见 .

    总结本地安装QML模块所需的所有步骤(在项目目录中):

    • 确保在* .pro中定义了var QML_IMPORT_PATHS

    QML_IMPORT_PATH = ./qmlModules

    • 在main.cpp中添加导入路径(对于qmake项目)

    int main(int argc,char * argv [])
    {
    QApplication app(argc,argv);

    QQmlApplicationEngine引擎;
    engine.addImportPath(QStringLiteral( “qmlModules”));
    engine.load(QUrl(QStringLiteral( “QRC:/analyzer.qml”)));

    return app.exec();
    }

    • 确保插件's files are correctly deployed. I' ve使用了来自here的解决方案

    copydata.commands = $(COPY_DIR)$$ PWD / qmlModules $$ OUT_PWD
    first.depends = $(first)copydata
    出口(first.depends)
    出口(copydata.commands)
    QMAKE_EXTRA_TARGETS =第一个copydata

相关问题