Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Best practice: Integrate .js file to a project
the question is, how to properly add a .js file to my project.
Currently, I have created a qrc file and add the .js file to it.
Now, I can reference to it with an import statement like this:
@import "qrc:/helper.js" as Helper@
This works, but the Qt Creator has marked this as an error with a red underline.
If I use loose .js files and reference with
@import "helper.js" as Helper@
this has to be deployed as a loose file, too. So, anyone can simply manipulate it.
So, what is the best way? Perhaps there are much more ways...
daliusd last edited by
You make wrong assumption that file in qrc can't be read or manipulated. I just did that with one core N9 app last month as I have tried to figure out what I should pass to it.
Ok, that's right.
But for a normal user, it is harder to access a qrc file than a plain file.
matti- last edited by
At least when the js/qml files are in the same qrc file, you can adress the .js files like so from QML:
import "helper.js" as Helper
even when theyre inside the qrc. This works with QtQuick2 at least.
this doesn't work for me.
The program didn't find the file.
Perhaps this is because of my mac system.
But in Qt Creator this is an error, too.