[Qt-interest] QWebView: getting events from javascript
Girish Ramakrishnan
girish at forwardbias.in
Thu Jul 23 23:29:11 CEST 2009
Lukas Lipavsky wrote:
> I am able to control the map from the outside with
> qwebview->page()->mainFrame()->evaluateJavaScript(). But I need also
> the other way. When the user drags a map or changes the zoom level, the
> map object triggers a bounds_changed event, which I can process inside
> javascript (shown in the code above). Is there some way to "propagate"
> it from javascript to the QWebView so I can handle it in the Qt application?
>
> I've found only one possible solution so far - polling: the event in
> javascript sets some js variable and Qt application polls this variable
> in regular time intervals...
>
> Is there any better way?
>
There's a better way - add a c++ object using
addToJavaScriptWindowObject(). From Javascript, instead of setting a js
variable, call a slot of the c++ object that you added.
Girish
More information about the Qt-interest-old
mailing list