Qml and javascript files in resource (qrc), how to import js in qml ?
-
-
try uppercase first letter for the qualifier;
eg import "qrc:/js/componentCreator" as Ccscript
-
yes,
@import "qrc:/js/componentCreator" as Ccscript@
but get another error : "qrc:/js/componentCreator": no such directory
qrc code here:
@<RCC>
<qresource prefix="/qml">
<file alias="main">qml/CC/main.qml</file>
</qresource>
<qresource prefix="/js">
<file alias="componentCreator">qml/CC/componentCreation.js</file>
</qresource>
</RCC>@ -
@import "qrc:/js/componentCreator.js" as Ccscript@
-
@import "qrc:/js/componentCreation.js" as Ccscript@
error:
qrc:/qml/main:2:1: Script qrc:/js/componentCreation.js unavailable
qrc:/js/componentCreation.js: File not foundor, full path
@import "qrc:/js/qml/CC/componentCreation.js" as Ccscript@
error:
qrc:/qml/main:2:1: Script qrc:/js/qml/CC/componentCreation.js unavailable
qrc:/js/qml/CC/componentCreation.js: File not found -
Hi,
If your main.qml is also in the resource file, you shouldn't need the qrc prefix for the import. http://doc.qt.nokia.com/4.7-snapshot/qtbinding.html#managing-resource-files-with-the-qt-resource-system gives further details on using the resource system with QML.
Regards,
Michael -
qrc prefix is not the Key. :(
-
Hi,
Just to clarify, by qrc prefix I meant qrc:.
I'd also suggest simplifying the qrc file by only using a single qresource prefix, to see if that is introducing any issues.
Regards,
Michael -
[quote author="mbrasser" date="1311135597"]Hi,
Just to clarify, by qrc prefix I meant qrc:.
I'd also suggest simplifying the qrc file by only using a single qresource prefix, to see if that is introducing any issues.
Regards,
Michael[/quote]thanks.
I think this is just a simple question, Is here no one encountered this?
-
need someone
-
Try to put ".js" in the alias like:
<file alias="componentCreator.js">qml/CC/componentCreation.js</file>