Unsolved QScriptEngine & QScriptContext How to use ?
-
I am using Qt 5.4.
When you write text in LineEdit or TextEdit and run the script, all text written in the widget is read and QScriptEngine-> evaluate () is executed.
For example,
var contents = "test"; And write
After reading all with QTextStream, execute QScriptEngine-> evaluate ()You can set and use values for contents in the script.
Once executed, I could get the value of at least test only for contents without the need for a separate declaration.QScriptEngine-> evaluate (), I thought that all previously written values were stored somewhere in the script, but when I ran another script file in the script, variables & functions were not saved.
Is there a way to write a function in the called script when another script file is called in the script?
-
Hi
You mean like this ?
https://stackoverflow.com/questions/39128858/is-there-a-way-to-maintain-qt-script-context-environment-outside-of-qscriptengin
Using pushContext -
I do not put it in the global object separately.
If you read the contents written in a text file and do scriptEngine-> evaluate (), it is automatically registered somewhere and you can use it without declaration.When calling another script from within the script, it seems that variables or functions in the other script cannot be saved.
-
- When calling another script from within the script, it seems that variables or functions in the other script cannot be saved.
What do you mean by saved?