Hi, I'm using QWebFrame's addToJavaScriptWindowObject function to extend the javascript API available. Mostly this is working great, I have a couple of questions though;
1. What's the best way of handling adding event listeners and raising events with my javascript API? Currently I'm using the following syntax to assign an event listener... JSBinding.onEvent = "CallFunction()"; and then I use QWebFrame's evaluateJavaScript to raise the event. This has a couple of down sides; Only one event listener can be registered at once, it's not easy to pass parameters into the function and it's handled differently to adding normal js event listeners. Is there any way to be able to pass a javascript function in so I can store that and then call it later on with the parameters I need? I've tried specifying the function's parameter as a QVariant but the function just seems to be provided as a VariantMap with 0 items. 2. Is it possible to return an object from a javascript call that behaves like an object added with addToJavaScriptWindowObject ? I can easily returns ints, strings, lists of strings and integers, etc. I've also been able to return the equivalent of a JSONified object (i.e. just data) by returning it as a QMap<QString, QVariant>, however what I would like to do is is return an object that has properties and methods (through slots) so the javascript can interact with my c++ objects directly. If I try to return an object I get a compiler error saying that QObject's copy constructor is private, if I return a pointer to an Object I get an empty string returned and if I try and return the object inside a QVariant I again get copy constructor compiler errors. I don't know if I'm doing something incorrectly to cause these compiler errors or if it's just not currently possible. Both of these issues I can easily work around (evaling code for 1 and providing a procedural style API for 2) so if these things are not possible it's not a huge deal. I just wanted to make sure I hadn't missed anything before I set my Javascript API in stone. Thanks, Mike
_______________________________________________ webkit-qt mailing list [email protected] http://lists.webkit.org/mailman/listinfo.cgi/webkit-qt
