我想把一些.qml文件放到文件夹里。
这行得通,
<RCC>
<qresource prefix="/">
<file>main.qml</file>
<file>other/Thing.qml</file>
</qresource>
</RCC>但这不是
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
<qresource prefix="/other">
<file>other/Thing.qml</file>
</qresource>
</RCC>我正在分离,因为下一步是将"/other“资源移动到一个单独的qrc文件中。
有什么帮助吗?谢谢。
编辑1:
我试过了,
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
<qresource prefix="/other">
<file>other/Thing.qml</file>
<file>other/qmldir</file>
</qresource>
</RCC>qmldir:
module Other
Thing 1.0 Thing.qml然后添加到main.qml:
import Other 1.0编辑#2
我尝试添加到main.cpp:
engine.addImportPath("other");或
engine.addImportPath("qrc:/other");不行。
发布于 2016-02-21 06:54:43
修复方法是在资源中添加导入路径。
engine.addImportPath("qrc:/Other");在这里设置的文件,
发布于 2016-02-19 16:53:03
我想当你引用“其他”文件夹时,你遇到的问题与字母大小写的不同有关。你有时用"Other",有时用"other“。
试试这个:
import other 1.0;而不是
import Other 1.0;似乎qt考虑的是文件夹的真实名称,而不是qmldir中指定的名称。
https://stackoverflow.com/questions/35460300
复制相似问题