[Interest] How to add global functions to a QJSEngine?

Bart Kelsey elbarto at gmail.com
Wed Jun 20 20:42:25 CEST 2012


Greets!

Using QScriptEngine, it was possible to add global javascript functions
(constructors for QObjects, etc).  With the new QJSEngine, which appears to
be in most ways roughly equivalent to QScriptEngine, there isn't an
immediately obvious way to do this.  Could someone shed some light on how I
might be able to add a function to the global object?

Also, I'm having a bit of trouble with context as well.  QJSEngine seems to
have an idea of what its current context *is*, but it doesn't appear that
there's a way to change that.  If I want to evaluate some javascript code
in a particular context, how do I go about that?  (Before someone points it
out, I realize you can call a QJSValue with a particular context, but that
isn't quite what I'm asking.)

Thanks!

Bart

-- 
--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120620/9a9bbf00/attachment.html>


More information about the Interest mailing list