Thanks Ariya,<div><br></div><div>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).</div><div><br></div>
<div>Is there any effort ever done for this or any ideas on how to make it work?</div><div><br></div><div>Sunny.</div><div><br><div class="gmail_quote">On Thu, Sep 15, 2011 at 3:30 AM, Ariya Hidayat <span dir="ltr"><<a href="mailto:ariya.hidayat@gmail.com">ariya.hidayat@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">> I found that, the actual problem is QtWebkitBridge does not provide a way<br>
> to, passing JS function to C++ slot and calling JS function from invoked C++<br>
> slot.<br>
<br>
</div>You can't do that at all because the bridge relies on QVariant and<br>
conversion to/from QVariant is lossy. Since QVariant is just a<br>
container for different opaque data type, it does not understand<br>
function and closure from the JS world.<br>
<br>
This problem might be solved in the future, iff the bridge exposes the<br>
object as e.g. QScriptValue like in QtScript module.<br>
<div class="im"><br>
> Now, as there is no functionality to call JS functions from the Invoked<br>
> Slot, we implemented a hack that is,<br>
> 1). While calling Qt Slot, QtWebKitBridge converts JS function to QString<br>
> datatype.<br>
> 2). we use QWebFrame::EvaluateJavaScript and connect success and failure JS<br>
> functions to two signals of the current object.<br>
> 3). Now, If we get success, we emit the success and failure signals and<br>
> connected JS functions gets called.<br>
> Now this hack does not work, if call to my slot is done with code like<br>
> below,<br>
> function analyzeImages() {<br>
> var strHello = "Hello World"<br>
> // Below is a call to slot<br>
> imageAnalyzer.startAnalysis( function () { alert(strHello); } );<br>
> }<br>
<br>
</div>Your hack breaks exactly when it involves closures, that's because the<br>
string representation of the (callback) function does not understand<br>
it.<br>
<br>
I am afraid there is no clean solution for your problem.<br>
<font color="#888888"><br>
<br>
<br>
--<br>
Ariya Hidayat, Passionate Technologist<br>
<a href="http://ariya.ofilabs.com" target="_blank">http://ariya.ofilabs.com</a><br>
</font></blockquote></div><br></div>