无法使用qrc加载.qml和.js文件

时间:2019-02-20 15:42:16

标签: qt qml qtquick2 qrc

我在我的QML项目中使用qChart.js,并且通过使用

将其导入QML能够很好地访问库。

import jbQuick.Charts 1.0

并通过对文件路径进行硬编码来添加资源路径

QQmlApplicationEngine engine;
engine.addImportPath("C:\\PathToProject\\qml\\");

但是,我想部署我的项目,并且不能使用硬编码的路径,因为这会因用户而异。我尝试添加this question中指定的文件,因此我的qrc现在具有以下内容:

enter image description here

我现在将我的addImportPath语句修改为以下内容:

engine.addImportPath("qrc:///qml");

但是,当使用qrc文件中包含的QChart.qmlQChart.js运行时,出现以下错误:

qmlcache_loader.obj:-1: error: LNK2001: unresolved external symbol "unsigned char const * const QmlCacheGeneratedCode::_qml_jbQuick_Charts_qml_jbQuick_Charts_QChart_js::qmlData" (?qmlData@_qml_jbQuick_Charts_qml_jbQuick_Charts_QChart_js@QmlCacheGeneratedCode@@3QBEB)
qmlcache_loader.obj:-1: error: LNK2001: unresolved external symbol "unsigned char const * const QmlCacheGeneratedCode::_qml_jbQuick_Charts_qml_jbQuick_Charts_QChart_qml::qmlData" (?qmlData@_qml_jbQuick_Charts_qml_jbQuick_Charts_QChart_qml@QmlCacheGeneratedCode@@3QBEB)

我的理解是,qmldir中引用的任何文件也必须添加到qrc文件中,即QChart.qmlQChart.js。我还应该补充一点,我正在发布模式下运行它。在调试模式下,我只会遇到module "jbQuick.Charts" is not installed错误。我在做什么错了?

0 个答案:

没有答案
相关问题