Quantcast
Channel: Qt DevNet forums: Qt WebKit
Viewing all articles
Browse latest Browse all 542

Qt bridge: how to receive JS objects

$
0
0
I have implemented a simple plugin using QWebPluginFactory and the Qt bridge. The plugin creates an object using my class, when the HTML contains an embedded object with the mime type I defined. According to http://qt-project.org/doc/qt-4.8/qtwebkit-bridge.html QWebElement A signal, slot or property that expects or returns a QWebElement can work seamlessly with JavaScript references to DOM elements. The JavaScript environment can select DOM elements, keep them in variables, then pass them to Qt as a QWebElement, and receive them back. So I defined a method in my class, like the following void MyClass::method1 (const QWebElement& object) { [...] } and another one like void MyClass::method2(QObject *object) { [...] } But none of them seem to give me access to the Javascript properties and methods of the incoming object, when this object is not an HTML, object. For example, using the following Javascript myobject = document.getElementById('myobject');   myargument = new Array();   myobject.method1(myargument);   /* The following call errors with 'Error: incompatible type of argument(s) in call to method2(); candidates were                                       method2(QObject*) */ myobject.method2(myargument); How can I receive a JS object in the methods I define and have access to its methods and properties?

Viewing all articles
Browse latest Browse all 542

Trending Articles