Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
agroyer last edited by
and import it into a qml file. For example:
import "factorial.js" as MathFunctions
charleyb last edited by
I spent a lot of time trying to answer that question: I think the answer is "No".
xsacha last edited by
There are workarounds (check Google).
An obvious one should be to instead import a QML file that imports a JS file. Then stack these to create as many layers as needed. Though I don't think it is recommended.
DenisKormalev last edited by
We had similar situation with QtScript, but there you can use scriptextensions to simulate such functionality. We have a lot of application logic in scripts, so it helped us. But such way is impossible now in qml, because scriptengine used by qml is private member and can't be accessed from your code. And I also don't know other ways to solve it.
2beers last edited by
I faced a similar situation. The only solution I found was to create a separate qml file and import all the JS files there.
Btw , it will be nice if it will be an import_once feature in QML.
blam last edited by
Actually, it is possible. All you need is to call
I'm certain this used to be in the docs. I've filed http://bugreports.qt.nokia.com/browse/QTBUG-15855 so the docs get fixed.