Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QWebFrame Class Reference
[QtWebKit module]

The QWebFrame class represents a frame in a web page. More...

 #include <QWebFrame>

Inherits QObject.

This class was introduced in Qt 4.4.

Properties

  • 1 property inherited from QObject

Public Functions

  • 29 public functions inherited from QObject

Public Slots

  • 1 public slot inherited from QObject

Signals

Additional Inherited Members

  • 5 static public members inherited from QObject
  • 7 protected functions inherited from QObject

Detailed Description

The QWebFrame class represents a frame in a web page.

QWebFrame represents a frame inside a web page. Each QWebPage object contains at least one frame, the main frame, obtained using QWebPage::mainFrame(). Additional frames will be created for HTML <frame> or <iframe> elements.

A frame can be loaded using load() or setUrl(). Alternatively, if you have the HTML content readily available, you can use setHtml() instead.

The page() function returns a pointer to the web page object. See Elements of QWebView for an explanation of how web frames are related to a web page and web view.

The title of an HTML frame can be accessed with the title() property. Additionally, a frame may also specify an icon, which can be accessed using the icon() property. If the title or the icon changes, the corresponding titleChanged() and iconChanged() signals will be emitted. The textSizeMultiplier() property can be used to change the overall size of the text displayed in the frame.

QWebFrame objects are created and controlled by the web page. You can connect to the web page's frameCreated() signal to be notified when a new frame is created.

The hitTestContent() function can be used to programmatically examine the contents of a frame.

A QWebFrame can be printed onto a QPrinter using the print() function. This function is marked as a slot and can be conveniently connected to QPrintPreviewDialog's paintRequested() signal.

See also QWebPage.


Property Documentation

contentsSize : const QSize

This property holds the size of the contents in this frame.

Access functions:

  • QSize contentsSize () const

icon : const QIcon

This property holds the icon associated with this frame.

Access functions:

  • QIcon icon () const

See also iconChanged() and QWebSettings::iconForUrl().

textSizeMultiplier : qreal

This property holds the scaling factor for all text in the frame.

Access functions:

  • qreal textSizeMultiplier () const
  • void setTextSizeMultiplier ( qreal factor )

title : const QString

This property holds the title of the frame as defined by the HTML <title> element.

Access functions:

  • QString title () const

See also titleChanged().

url : QUrl

This property holds the url of the frame currently viewed.

Access functions:

  • QUrl url () const
  • void setUrl ( const QUrl & url )

See also urlChanged().


Member Function Documentation

void QWebFrame::addToJavaScriptWindowObject ( const QString & name, QObject * object )

Make object available under name from within the frame's JavaScript context. The object will be inserted as a child of the frame's window object.

Qt properties will be exposed as JavaScript properties and slots as JavaScript methods.

If you want to ensure that your QObjects remain accessible after loading a new URL, you should add them in a slot connected to the javaScriptWindowObjectCleared() signal.

QList<QWebFrame *> QWebFrame::childFrames () const

Returns a list of all frames that are direct children of this frame.

See also parentFrame().

QVariant QWebFrame::evaluateJavaScript ( const QString & scriptSource )   [slot]

Evaluate JavaScript defined by scriptSource using this frame as context.

See also addToJavaScriptWindowObject() and javaScriptWindowObjectCleared().

QString QWebFrame::frameName () const

The name of this frame as defined by the parent frame.

QRect QWebFrame::geometry () const

Return the geometry of the frame relative to it's parent frame.

QWebHitTestResult QWebFrame::hitTestContent ( const QPoint & pos ) const

Performs a hit test on the frame contents at the given position pos and returns the hit test result.

void QWebFrame::iconChanged ()   [signal]

This signal is emitted when the icon ("favicon") associated with the frame has been loaded.

See also icon().

void QWebFrame::initialLayoutCompleted ()   [signal]

This signal is emitted when the frame is laid out the first time. This is the first time you will see contents displayed on the frame.

Note: A frame can be laid out multiple times.

void QWebFrame::javaScriptWindowObjectCleared ()   [signal]

This signal is emitted whenever the global window object of the JavaScript environment is cleared, e.g., before starting a new load.

If you intend to add QObjects to a QWebFrame using addToJavaScriptWindowObject(), you should add them in a slot connected to this signal. This ensures that your objects remain accessible when loading new URLs.

void QWebFrame::load ( const QUrl & url )

Loads url into this frame.

Note: The view remains the same until enough data has arrived to display the new url.

See also setUrl(), setHtml(), and setContent().

void QWebFrame::load ( const QWebNetworkRequest & req )

This is an overloaded member function, provided for convenience.

Loads a network request, req, into this frame.

Note: The view remains the same until enough data has arrived to display the new url.

QWebPage * QWebFrame::page () const

The web page that contains this frame.

QWebFrame * QWebFrame::parentFrame () const

Returns the parent frame of this frame, or 0 if the frame is the web pages main frame.

This is equivalent to qobject_cast<QWebFrame*>(frame->parent()).

See also childFrames().

QPoint QWebFrame::pos () const

Returns the position of the frame relative to it's parent frame.

void QWebFrame::print ( QPrinter * printer ) const   [slot]

Prints the frame to the given printer.

See also render().

void QWebFrame::render ( QPainter * painter, const QRegion & clip )

Render the frame into painter clipping to clip.

See also print().

void QWebFrame::render ( QPainter * painter )

This is an overloaded member function, provided for convenience.

Render the frame into painter.

QString QWebFrame::renderTreeDump () const

Returns a dump of the rendering tree. This is mainly useful for debugging html.

int QWebFrame::scrollBarMaximum ( Qt::Orientation orientation ) const

Returns the maximum value for the scrollbar with orientation orientation, or 0 if no scrollbar is found for orientation.

See also scrollBarMinimum().

int QWebFrame::scrollBarMinimum ( Qt::Orientation orientation ) const

Returns the minimum value for the scrollbar with orientation orientation.

The minimum value is always 0.

See also scrollBarMaximum().

Qt::ScrollBarPolicy QWebFrame::scrollBarPolicy ( Qt::Orientation orientation ) const

Returns the scrollbar policy for the scrollbar defined by orientation.

See also setScrollBarPolicy().

int QWebFrame::scrollBarValue ( Qt::Orientation orientation ) const

Returns the current value for the scrollbar with orientation orientation, or 0 if no scrollbar is found for orientation.

See also setScrollBarValue(), scrollBarMinimum(), and scrollBarMaximum().

void QWebFrame::setContent ( const QByteArray & data, const QString & mimeType = QString(), const QUrl & baseUrl = QUrl() )

Sets the content of this frame to the specified content data. If the mimeType argument is empty it is currently assumed that the content is HTML but in future versions we may introduce auto-detection.

External objects referenced in the content are located relative to baseUrl.

See also toHtml().

void QWebFrame::setHtml ( const QString & html, const QUrl & baseUrl = QUrl() )

Sets the content of this frame to html. baseUrl is optional and used to resolve relative URLs in the document.

When using this method WebKit assumes that external resources such as JavaScript programs or style sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified through the charset attribute of the HTML script tag. It is also possible for the encoding to be specified by web server.

See also toHtml().

void QWebFrame::setScrollBarPolicy ( Qt::Orientation orientation, Qt::ScrollBarPolicy policy )

Sets the scrollbar policy for the scrollbar defined by orientation to policy.

See also scrollBarPolicy().

void QWebFrame::setScrollBarValue ( Qt::Orientation orientation, int value )

Sets the current value for the scrollbar with orientation orientation.

The scrollbar forces the value to be within the legal range: minimum <= value <= maximum.

Changing the value also updates the thumb position.

See also scrollBarValue(), scrollBarMinimum(), and scrollBarMaximum().

void QWebFrame::titleChanged ( const QString & title )   [signal]

This signal is emitted whenever the title of the frame changes. The title string specifies the new title.

See also title().

QString QWebFrame::toHtml () const

Returns the frame's content, converted to HTML.

See also setHtml() and toPlainText().

QString QWebFrame::toPlainText () const

Returns the content of this frame converted to plain text.

See also toHtml().

void QWebFrame::urlChanged ( const QUrl & url )   [signal]

This signal is emitted with the URL of the frame when the frame's title is received. The new URL is specified by url.

See also url().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 44
  2. Microsoft ouvre aux autres compilateurs C++ AMP, la spécification pour la conception d'applications parallèles C++ utilisant le GPU 22
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. RIM : « 13 % des développeurs ont gagné plus de 100 000 $ sur l'AppWord », Qt et open-source au menu du BlackBerry DevCon Europe 0
  5. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
Page suivante

Le Qt Quarterly au hasard

Logo

XQuery et la météo

Qt Quarterly est la revue trimestrielle proposée par Nokia et à destination des développeurs Qt. Ces articles d'une grande qualité technique sont rédigés par des experts Qt. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt qtextended4.4
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web