[webkit-qt] [QtWebkitBridge] local function variables not accessible!

sunny shah sunny.cpp at gmail.com
Wed Sep 14 15:15:44 PDT 2011


Thanks Ariya,

Thanks for your input, I will have a look at QtScript implementation to
check, how to make this working ( as We will have to patch QtWebkit for neat
JS function calling).

Is there any effort ever done for this or any ideas on how to make it work?

Sunny.

On Thu, Sep 15, 2011 at 3:30 AM, Ariya Hidayat <ariya.hidayat at gmail.com>wrote:

> > I found that, the actual problem is QtWebkitBridge does not provide a way
> > to, passing JS function to C++ slot and calling JS function from invoked
> C++
> > slot.
>
> You can't do that at all because the bridge relies on QVariant and
> conversion to/from QVariant is lossy. Since QVariant is just a
> container for different opaque data type, it does not understand
> function and closure from the JS world.
>
> This problem might be solved in the future, iff the bridge exposes the
> object as e.g. QScriptValue like in QtScript module.
>
> > Now, as there is no functionality to call JS functions from the Invoked
> > Slot, we implemented a hack that is,
> > 1). While calling Qt Slot, QtWebKitBridge converts JS function to QString
> > datatype.
> > 2). we use QWebFrame::EvaluateJavaScript and connect success and failure
> JS
> > functions to two signals of the current object.
> > 3). Now, If we get success, we emit the success and failure signals and
> > connected JS functions gets called.
> > Now this hack does not work, if call to my slot is done with code like
> > below,
> > function analyzeImages() {
> >   var strHello = "Hello World"
> >  // Below is a call to slot
> >   imageAnalyzer.startAnalysis( function () { alert(strHello); } );
> > }
>
> Your hack breaks exactly when it involves closures, that's because the
> string representation of the (callback) function does not understand
> it.
>
> I am afraid there is no clean solution for your problem.
>
>
>
> --
> Ariya Hidayat, Passionate Technologist
> http://ariya.ofilabs.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20110915/3ed2c0ac/attachment.html>


More information about the webkit-qt mailing list