1

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?

0

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.