Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

Add both js files in your program. The order of adding those is:

  1. another.js file
  2. test.js file

Then you can call the function directly if you defined it in global scope(window scope), like :

In another js :

function myFunc() { /* your code here */ }

In test.js:

myFunc();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top