Strings and other QtScript objects that Qt Scripting can cast directly can be stored in objects.
All global objects do not automatically persist when the User closes Tw.
If you have difficulties, the safest bet are simple things like numerical values and strings - and don't forget JSON structures.
Once stored (with a name created by the script writer), the global can be tested for (by name - does it exist already? - hasGlobal) and be re-read back into QtScript.
Globals are stored for as long as the Tw editor is still running, and should be retrieved and formatted (possibly json) and saved to disk if required for later use.
There are two types of Globals.
Returns a boolean (true or false ) showing whether the global has already been created and set.
The object should be one that Qt can cast (convert) from QtScript see table here:
If you have difficulties, the safest bet are simple things like numerical values and strings.
var myGlobalVariable = TW.app.getGlobal("font_name");
var myScriptVariable = TW.script.getGlobal("anyThing_you_like");
Returns the global named, to script, and stores it in the variable name you supply.
Use hasGlobal first if unsure of its existence.
Oops, I think that was overlooked when the "globals" framework was
I added the two functions TW.app.unsetGlobal("foo") and
TW.script.unsetGlobal("foo") in r994. They should do just what you want.
void TWApp::setGlobal(const QString& key, const QVariant& val)
Created with the Personal Edition of HelpNDoc: Full featured Documentation generator