Search code examples
javascriptc++qtqtscript

How can I call another QtScript .js file from one QtScript .js file


now I can use QScriptEngine to load and execute a test.js file. In one of the function of that test.js I'd like to call another function located in another .js file. How do I do this?


Solution

  • To load QTScript Code from multiple files you need to load all those file using QScriptEngine.evaluate(). Then those methods will be available to all the JS environment according to the rules of JS. ie: you will be able access global methods directly.

    But if you are working on a big project, I would strongly suggest you use some common JS implementation in QT. I have worked on a fairly large project on QTScript and it used work great for us. Here is a link which goes into little detail of how you can implement that in QT.