QScriptEngine has evaluate() method that can be used to load script, execute it and to run a specified function from already loaded script. But how to clear current script and load a new one? For example, i use evaluate() to load a script from file and then evaluate() to get a script functions and call them. But what can i do to clear current script and load a new one from a different file? Deleting and creating QScriptEngine seems like a solution, but it likes to be created in GUI thread (due to QScriptEngineDebugger) while all script operations are performed in separate thread. So is it any way to clear current script without re-creating QScriptEngine object?
engine.pushContext();
engine.evaluate("...");
engine.popContext();
engine.pushContext();
engine.evaluate("...");
engine.popContext();
Calling pushContext() before evaluating a script and calling popContext() before evaluating a new script will effectively clear all script data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With