[webkit-qt] Nested objects with QtWebKit bridge

Loïc Yhuel loic.yhuel_ext at softathome.com
Wed Aug 24 03:42:23 PDT 2011


I want to define Q_INVOKABLE methods f1 and f2 in C++, which can be 
called in JS by A.f1() and A.B.f2()

As explained in the documentation, I can't add B class as a property of A.
The only workaround I found is :
webFrame->addToJavaScriptWindowObject("A", myA);
webFrame->addToJavaScriptWindowObject("_B", myB);
webFrame->evaluateJavaScript("A.B = _B");

I there a better way ?

More information about the webkit-qt mailing list