[webkit-qt] JS to C++ communication

Luciano Montanaro mikelima at cirulla.net
Sun Nov 8 07:27:21 PST 2009


On domenica 08 novembre 2009, Venu Vemulapally wrote:
> Hi All,
>    we have ported QtWebkit on to ARM platform successfully. We have written
> a JS application which should call the C APIs from JS. how to communicate
> from JS to C++, Cpuld you please suggest me ?
> 
> 
> Thanks,
> Venu
> 

Depending on what exactly you need to do, it could be easy enough, or 
difficult.

For the simpler case, where you just want to add an interface to one of your 
classes, you just need to create a QObject and mark your methods as slots.

See the QWebFrame documentation page.
Check the addToJavaScriptWindowObject and javaScriptWindowObjectCleared
methods.

If you need to return JavaScript objects or arrays from your method, it's 
something I'm looking into at the moment -- is it possible at all? Is there a 
way to obtain the page interpreter, or the current execution context?

Luciano 

-- 
Luciano Montanaro //
                \X/ mikelima at cirulla.net


More information about the webkit-qt mailing list