Solved QScriptContext::pushScope() undocumented
-
QScriptContext::pushScope() and popScope() seem to be present since 4.5, but undocumented in all versions. Why is this? Should I not use it?
-
Hi,
That function is marked internal.
-
@JCipriani said in QScriptContext::pushScope() undocumented:
QScriptContext::pushScope() and popScope() seem to be present since 4.5, but undocumented in all versions. Why is this? Should I not use it?
If a function is not documented, that means it's not part of the public API. It is not meant to be used. Undocumented functions can be modified/removed at any time. If you call any undocumented functions, your code could break when you upgrade from, say,
Qt 5.x
toQt 5.(x+1)
.In contrast, functions that are documented (i.e. part of the public API) are guaranteed to remain compatible until at least Qt 6.
-
Thanks.
Then is there any other way to set up local script vars programmatically, but set them up outside push/popContext calls so that the vars don't need to be re-set every time?
Like with pushScope I could set up a QScriptValue containing a local environment ahead of time, then reuse it as necessary without having to set it up again every time a context is pushed.
Sort of like if I had the ability to create a QScriptContext and tell the engine to use it, instead of having create + push be inseparable as it is with pushContext.
-
I'm not familiar with the Qt Script module, sorry.
In this particular case, given that
QScriptContext::pushScope()
has been unchanged since Qt 4.5, and given that the Qt Script module is now deprecated (which means no more work is being done on it), I think it's safe to assume that the function will never be changed. If you've got an existing project that callsQScriptContext::pushScope()
, you can continue using it,The bigger risk to consider is that all
QScript*
classes and functions might stop being included in official builds in the future (i.e. you might have to build the module yourself if you want to upgrade Qt while continuing to use Qt Script)Have you seen
QJSEngine
? The Qt devs want this to replaceQScriptEngine
, although some functionality in Qt Script isn't available in the newer module yet.