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

Alexis Menard alexis.menard at openbossa.org
Wed Sep 14 13:45:30 PDT 2011


On Sep 14, 2011, at 5:33 PM, sunny shah wrote:

> Hi,
> 
> Suppose, below is my JS Code in html file
> 
> function analyzeImages() {
>   var strHello = "Hello World"
>   imageAnalyzer.startAnalysis();
> }
> 
> Now, Here is a startAnalyzer slot code in C++ 
> void ImageAnalyzer::startAnalysis() {
> // Below code works ( Gives message box )
> ((MainWin*)parent())->page()->mainFrame()->evaluateJavaScript("alert('Qt is good'); ");
> // Now below line does not work.
> ((MainWin*)parent())->page()->mainFrame()->evaluateJavaScript("alert(strHello); ");
>  // do something
> }
> 
> 1). Any idea, how to make it work? 

Just put the variable in the global object, i.e. a global variable.

> 2). If it is not supported by QtWebkitBridge, then can you please tell me what was the reason behind it?

How do you expect the C++ slot to know about the JS context of the fct? Magic?

> 3). It is very important for us to make this work, can you please tell me how to do this?
> 
> Thanks,
>  Sunny.
> _______________________________________________
> webkit-qt mailing list
> webkit-qt at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt



More information about the webkit-qt mailing list