Unless you were suggesting accessing the property values / methods of C++
objects added to the context of the QML document, and passing the values to
WebKit using evalulateJavaScript? However this does not allow for WebKit to
call methods on C++ objects or the QML file.

On Mon, May 10, 2010 at 11:50 AM, Jack Wootton <[email protected]>wrote:

>
>
> On Fri, May 7, 2010 at 7:15 AM, Jack Wootton <[email protected]>wrote:
>
>> Thank you for this clarification and clear example.  I'm very impressed so
>> far with the flexibility QML provides in terms of communication between C++
>> > QML > JavaScript Context.
>>
>>
>> On Fri, May 7, 2010 at 6:52 AM, <[email protected]> wrote:
>>
>>>  Hi,
>>>
>>> Yes the documentation is out of date.  The fact that the property is
>>> marked as read-only is a qdoc bug.
>>>
>>> I’ve updated the docs.  As it will take a while to make it through our CI
>>> system, I’ve included the change here.
>>>
>>> /*!
>>>     \qmlproperty list<object> WebView::javaScriptWindowObjects
>>>
>>>     A list of QML objects to expose to the web page.
>>>
>>>     Each object will be added as a property of the web frame's window
>>> object.  The
>>>     property name is controlled by the value of \c
>>> WebView.windowObjectName
>>>     attached property.
>>>
>>>     Exposing QML objects to a web page allows JavaScript executing in the
>>> web
>>>     page itself to communicate with QML, by reading and writing
>>> properties and
>>>     by calling methods of the exposed QML objects.
>>>
>>>     This example shows how to call into a QML method using a window
>>> object.
>>>
>>>     \qml
>>>     WebView {
>>>         javaScriptWindowObjects: QtObject {
>>>             WebView.windowObjectName: "qml"
>>>
>>>             function qmlCall() {
>>>                 console.log("This call is in QML!");
>>>             }
>>>         }
>>>
>>>         html: "<script>console.log(\"This is in WebKit!\");
>>> window.qml.qmlCall();</script>"
>>>     }
>>>     \endqml
>>>
>>>     The output of the example will be:
>>>     \code
>>>     This is in WebKit!
>>>     This call is in QML!
>>>     \endcode
>>>
>>>     If Javascript is not enabled for the page, then this property does
>>> nothing.
>>> */
>>>
>>> As an aside, there is also a bug that prevents calling methods declared
>>> in QML (like that in the example), but there is also a fix for that working
>>> through our system.  For the time being, you can communicate using property
>>> values or methods defined in C++.
>>>
>>
> I have tried using the example code oyu provided, and as you pointed out,
> it doesn't work.  You suggest and alternative of using property values or
> methods defined in C++, but how are these made available to WebKit?  I have
> added a C++ object to the context the QML document is loaded into, but this
> doesn't make the objet accessible from within Webkit.
>
>
>>
>>> Cheers,
>>>
>>> Aaron
>>>
>>>
>>> On 6/05/10 11:43 PM, "ext Jack Wootton" <[email protected]> wrote:
>>>
>>> It seems the wording of the documentation has been copied from the
>>> documentation for QWebFrame::addToJavaScriptWindowObject in Qt 4.6:
>>>
>>> http://doc.qt.nokia.com/4.6/qwebframe.html#addToJavaScriptWindowObject
>>>
>>> Is the reason for the confusing documentation?
>>>
>>> Cheers,
>>> Jack
>>>
>>> On Thu, May 6, 2010 at 2:37 PM, Jack Wootton <[email protected]>
>>> wrote:
>>>
>>> Hello,
>>>
>>> I hope someone can provide clarification on the documentation for QML
>>> WebView.
>>>
>>> Reading the documentation for Qt 4.7 QML WebView, specifically the
>>> property javaScriptWindowObjects:
>>>
>>>
>>> http://doc.qt.nokia.com/4.7-snapshot/qml-webview.html#javaScriptWindowObjects-prop
>>>
>>> Firstly the documentation states: "This property is a list of object that
>>> are available from within the webview's JavaScript context.". So this
>>> returns a list of all objects available in the JavaScript context for the
>>> document the WebView is currently displaying?  I expect this would include
>>> objects such as "document" and "window"?
>>>
>>> Secondly the documentation states: "The *object* will be inserted as a
>>> child of the frame's window object, under the name given by the attached
>>> property WebView.windowObjectName.".  This seems at odss with a
>>> read-only property?  It seems to suggest that C++ objects can be made
>>> available in the JavaScipt context of the document currently being displayed
>>> in the WebView?
>>>
>>> Thirdly the documentation states: "Properties of the object will be
>>> exposed as JavaScript properties and slots as JavaScript methods.".  Again,
>>> I do not understand how C++ objects can be made inserted into a JavaScript
>>> context using a read-only property of WebView.
>>>
>>> Lastly, an example is given:
>>>
>>> WebView {
>>>
>>>
>>>
>>>      javaScriptWindowObjects: Object {
>>>          WebView.windowObjectName: "coordinates"
>>>      }
>>>  }
>>>
>>> In this example, what is "Object"? A C++ object?  A JavaScript object?
>>>
>>>
>>
>>
>> --
>> Regards
>> Jack
>>
>
>
>
> --
> Regards
> Jack
>



-- 
Regards
Jack
_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to