Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, April 2008
addToJavaScriptWindowObject


Message 1 in thread

HI!

I am excited about the QtWebkit integration and doing some exepriments with the JavaScript bindings.

If I have an object created at the time of creating the BrowserApplication object, for example in the demo browser. If I want that object to be exported to the Java Script environment, do I need to export this object for each and every frame being created? 

If yes how and where should I export so that it's available to a Java Script having chance of running from any of the frames at a given time.

Also I could not make out the difference between a QWebPage and a QWebView.

regards

-Nitin

Send instant messages to your online friends http://uk.messenger.yahoo.com

--
 [ signature omitted ] 

Message 2 in thread

On Thursday 24 April 2008 15:34:12 Nitin Mahajan wrote:
> HI!
>
> I am excited about the QtWebkit integration and doing some exepriments with
> the JavaScript bindings.
>
> If I have an object created at the time of creating the BrowserApplication
> object, for example in the demo browser. If I want that object to be
> exported to the Java Script environment, do I need to export this object
> for each and every frame being created?

Yes.

> If yes how and where should I export so that it's available to a Java
> Script having chance of running from any of the frames at a given time.

We've recently updated the documentation that explains the quirks of exporting 
objects to the JavaScript environment. You may find the documentation of
QWebFrame::addToJavaScriptWindowObject helpful:

http://doc.trolltech.com/4.4-snapshot/qwebframe.html#addToJavaScriptWindowObject

QWebPage in turn has a signal that informs you about the creation of new 
frames (besides the main frame):

http://doc.trolltech.com/4.4-snapshot/qwebpage.html#frameCreated

> Also I could not make out the difference between a QWebPage and a QWebView.

The QWebView documentation has a beautiful flowchart that illustrates the 
relation between QWebPage and QWebView:

http://doc.trolltech.com/4.4-snapshot/qwebview.html

Basically QWebPage holds frames, settings and other objects together, but it 
is not a QWidget. So it can be used in non-QWidget environments, for example 
when printing. QWebView is a convenience widget that uses QWebPage and 
QWebFrame.


Simon

Attachment:

Attachment: signature.asc
Description: This is a digitally signed message part.


Message 3 in thread



--- On Thu, 24/4/08, Simon Hausmann <simon.hausmann@xxxxxxxxxxxxx> wrote:

> From: Simon Hausmann <simon.hausmann@xxxxxxxxxxxxx>
> Subject: Re: addToJavaScriptWindowObject
> To: qt-interest@xxxxxxxxxxxxx
> Date: Thursday, 24 April, 2008, 7:31 PM
> On Thursday 24 April 2008 15:34:12 Nitin Mahajan wrote:
> > HI!
> >
> > I am excited about the QtWebkit integration and doing
> some exepriments with
> > the JavaScript bindings.
> >
> > If I have an object created at the time of creating
> the BrowserApplication
> > object, for example in the demo browser. If I want
> that object to be
> > exported to the Java Script environment, do I need to
> export this object
> > for each and every frame being created?
> 
> Yes.

Thanks for the detailed information. Will it be enough to export just for the main frame?
> 
> > If yes how and where should I export so that it's
> available to a Java
> > Script having chance of running from any of the frames
> at a given time.
> 
> We've recently updated the documentation that explains
> the quirks of exporting 
> objects to the JavaScript environment. You may find the
> documentation of
> QWebFrame::addToJavaScriptWindowObject helpful:
> 
> http://doc.trolltech.com/4.4-snapshot/qwebframe.html#addToJavaScriptWindowObject
> 
> QWebPage in turn has a signal that informs you about the
> creation of new 
> frames (besides the main frame):
> 
> http://doc.trolltech.com/4.4-snapshot/qwebpage.html#frameCreated
> 
> > Also I could not make out the difference between a
> QWebPage and a QWebView.
> 
> The QWebView documentation has a beautiful flowchart that
> illustrates the 
> relation between QWebPage and QWebView:
> 
> http://doc.trolltech.com/4.4-snapshot/qwebview.html
> 
> Basically QWebPage holds frames, settings and other objects
> together, but it 
> is not a QWidget. So it can be used in non-QWidget
> environments, for example 
> when printing. QWebView is a convenience widget that uses
> QWebPage and 
> QWebFrame.
> 
> 
> Simon



Send instant messages to your online friends http://uk.messenger.yahoo.com

--
 [ signature omitted ] 

Message 4 in thread

On Thursday 24 April 2008 19:00:38 Nitin Mahajan wrote:
> --- On Thu, 24/4/08, Simon Hausmann <simon.hausmann@xxxxxxxxxxxxx> wrote:
> > From: Simon Hausmann <simon.hausmann@xxxxxxxxxxxxx>
> > Subject: Re: addToJavaScriptWindowObject
> > To: qt-interest@xxxxxxxxxxxxx
> > Date: Thursday, 24 April, 2008, 7:31 PM
> >
> > On Thursday 24 April 2008 15:34:12 Nitin Mahajan wrote:
> > > HI!
> > >
> > > I am excited about the QtWebkit integration and doing
> >
> > some exepriments with
> >
> > > the JavaScript bindings.
> > >
> > > If I have an object created at the time of creating
> >
> > the BrowserApplication
> >
> > > object, for example in the demo browser. If I want
> >
> > that object to be
> >
> > > exported to the Java Script environment, do I need to
> >
> > export this object
> >
> > > for each and every frame being created?
> >
> > Yes.
>
> Thanks for the detailed information. Will it be enough to export just for
> the main frame?

If the documents you're viewing does not consist of multiple frames then yes. 
Objects added to a frame's JavaScript window object are not automatically 
also populated to the child frame's window objects.

Simon

Attachment:

Attachment: signature.asc
Description: This is a digitally signed message part.