|  | Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# QWebPage Class Reference

The QWebPage class provides a widget that is used to view and edit web documents. More...

     #include <QWebPage>

Inherits QObject.

This class was introduced in Qt 4.4.

- List of all members, including inherited members

### Public Types

- enum NavigationRequestResponse { AcceptNavigationRequest, IgnoreNavigationRequest }
- enum NavigationType { NavigationTypeLinkClicked, NavigationTypeFormSubmitted, NavigationTypeBackForward, NavigationTypeReload, NavigationTypeFormResubmitted, NavigationTypeOther }
- enum WebAction { NoWebAction, OpenLink, OpenLinkInNewWindow, OpenFrameInNewWindow, ..., InspectElement }

### Properties

- modified : const bool
- selectedText : const QString
- viewportSize : QSize

- 1 property inherited from QObject

### Public Functions

- QWebPage ( QObject * parent = 0 )
- ~QWebPage ()
- QAction * action ( WebAction action ) const
- quint64 bytesReceived () const
- QWebFrame * currentFrame () const
- virtual bool focusNextPrevChild ( bool next )
- QWebHistory * history () const
- bool isModified () const
- QWebFrame * mainFrame () const
- QWebNetworkInterface * networkInterface () const
- QNetworkProxy networkProxy () const
- QString selectedText () const
- void setNetworkInterface ( QWebNetworkInterface * interface )
- void setNetworkProxy ( const QNetworkProxy & proxy )
- void setView ( QWidget * view )
- void setViewportSize ( const QSize & size ) const
- QWebSettings * settings ()
- quint64 totalBytes () const
- virtual void triggerAction ( WebAction action, bool checked = false )
- QUndoStack * undoStack () const
- QWidget * view () const
- QSize viewportSize () const

- 29 public functions inherited from QObject

### Signals

- void frameCreated ( QWebFrame * frame )
- void geometryChangeRequest ( const QRect & geom )
- void hoveringOverLink ( const QString & link, const QString & title, const QString & textContent = QString() )
- void loadProgressChanged ( int progress )
- void selectionChanged ()
- void statusBarTextChanged ( const QString & text )

- 1 signal inherited from QObject

### Protected Functions

- virtual QString chooseFile ( QWebFrame * parentFrame, const QString & oldFile )
- virtual QWebPage * createModalDialog ()
- virtual QObject * createPlugin ( const QString & classid, const QUrl & url, const QStringList & paramNames, const QStringList & paramValues )
- virtual QWebPage * createWindow ()
- virtual void javaScriptAlert ( QWebFrame * frame, const QString & msg )
- virtual bool javaScriptConfirm ( QWebFrame * frame, const QString & msg )
- virtual void javaScriptConsoleMessage ( const QString & message, unsigned int lineNumber, const QString & sourceID )
- virtual bool javaScriptPrompt ( QWebFrame * frame, const QString & msg, const QString & defaultValue, QString * result )
- virtual NavigationRequestResponse navigationRequested ( QWebFrame * frame, const QWebNetworkRequest & request, NavigationType type )
- virtual QString userAgentFor ( const QUrl & url ) const

- 7 protected functions inherited from QObject

### Additional Inherited Members

- 1 public slot inherited from QObject
- 5 static public members inherited from QObject

## Detailed Description

The QWebPage class provides a widget that is used to view and edit web documents.

QWebPage holds a main frame responsible for web content, settings, the history of navigated links as well as actions. This class can be used, together with QWebFrame, if you want to provide functionality like QWebView in a setup without widgets.

## Member Type Documentation

### enum QWebPage::NavigationRequestResponse

### enum QWebPage::NavigationType

### enum QWebPage::WebAction

Constant | Value | Description
--- | --- | ---
`QWebPage::NoWebAction` | `-1` | No action is triggered.
`QWebPage::OpenLink` | `0` | Open the current link.
`QWebPage::OpenLinkInNewWindow` | `1` | Open the current link in a new window.
`QWebPage::OpenFrameInNewWindow` | `2` | Replicate the current frame in a new window.
`QWebPage::DownloadLinkToDisk` | `3` | Download the current link to the disk.
`QWebPage::CopyLinkToClipboard` | `4` | Copy the current link to the clipboard.
`QWebPage::OpenImageInNewWindow` | `5` | Open the highlighted image in a new window.
`QWebPage::DownloadImageToDisk` | `6` | Download the highlighted image to the disk.
`QWebPage::CopyImageToClipboard` | `7` | Copy the highlighted image to the clipboard.
`QWebPage::GoBack` | `8` | Navigate back in the history of navigated links.
`QWebPage::GoForward` | `9` | Navigate forward in the history of navigated links.
`QWebPage::Stop` | `10` | Stop loading the current page.
`QWebPage::Reload` | `11` | Reload the current page.
`QWebPage::Cut` | `12` | Cut the content currently selected into the clipboard.
`QWebPage::Copy` | `13` | Copy the content currently selected into the clipboard.
`QWebPage::Paste` | `14` | Paste content from the clipboard.
`QWebPage::Undo` | `15` | Undo the last editing action.
`QWebPage::Redo` | `16` | Redo the last editing action.
`QWebPage::MoveToNextChar` | `17` | Move the cursor to the next character.
`QWebPage::MoveToPreviousChar` | `18` | Move the cursor to the previous character.
`QWebPage::MoveToNextWord` | `19` | Move the cursor to the next word.
`QWebPage::MoveToPreviousWord` | `20` | Move the cursor to the previous word.
`QWebPage::MoveToNextLine` | `21` | Move the cursor to the next line.
`QWebPage::MoveToPreviousLine` | `22` | Move the cursor to the previous line.
`QWebPage::MoveToStartOfLine` | `23` | Move the cursor to the start of the line.
`QWebPage::MoveToEndOfLine` | `24` | Move the cursor to the end of the line.
`QWebPage::MoveToStartOfBlock` | `25` | Move the cursor to the start of the block.
`QWebPage::MoveToEndOfBlock` | `26` | Move the cursor to the end of the block.
`QWebPage::MoveToStartOfDocument` | `27` | Move the cursor to the start of the document.
`QWebPage::MoveToEndOfDocument` | `28` | Move the cursor to the end of the document.
`QWebPage::SelectNextChar` | `29` | Select to the next character.
`QWebPage::SelectPreviousChar` | `30` | Select to the previous character.
`QWebPage::SelectNextWord` | `31` | Select to the next word.
`QWebPage::SelectPreviousWord` | `32` | Select to the previous word.
`QWebPage::SelectNextLine` | `33` | Select to the next line.
`QWebPage::SelectPreviousLine` | `34` | Select to the previous line.
`QWebPage::SelectStartOfLine` | `35` | Select to the start of the line.
`QWebPage::SelectEndOfLine` | `36` | Select to the end of the line.
`QWebPage::SelectStartOfBlock` | `37` | Select to the start of the block.
`QWebPage::SelectEndOfBlock` | `38` | Select to the end of the block.
`QWebPage::SelectStartOfDocument` | `39` | Select to the start of the document.
`QWebPage::SelectEndOfDocument` | `40` | Select to the end of the document.
`QWebPage::DeleteStartOfWord` | `41` | Delete to the start of the word.
`QWebPage::DeleteEndOfWord` | `42` | Delete to the end of the word.
`QWebPage::SetTextDirectionDefault` | `43` | Set the text direction to the default direction.
`QWebPage::SetTextDirectionLeftToRight` | `44` | Set the text direction to left-to-right.
`QWebPage::SetTextDirectionRightToLeft` | `45` | Set the text direction to right-to-left.
`QWebPage::ToggleBold` | `46` | Toggle the formatting between bold and normal weight.
`QWebPage::ToggleItalic` | `47` | Toggle the formatting between italic and normal style.
`QWebPage::ToggleUnderline` | `48` | Toggle underlining.
`QWebPage::InspectElement` | `49` | Show the Web Inspector with the currently highlighted HTML element.

## Property Documentation

### modified : const bool

Specifies if the page contains unsubmitted form data.

Access functions:

- bool isModified () const

### selectedText : const QString

Returns the text currently selected.

Access functions:

- QString selectedText () const

### viewportSize : QSize

Specifies the size of the viewport. The size affects for example the visibility of scrollbars if the document is larger than the viewport.

Access functions:

- QSize viewportSize () const
- void setViewportSize ( const QSize & size ) const

## Member Function Documentation

### QWebPage::QWebPage ( QObject * parent = 0 )

Constructs an empty QWebView with parent parent.

### QWebPage::~QWebPage ()

Destructor.

### QAction * QWebPage::action ( WebAction action ) const

Returns a QAction for the specified WebAction action.

The action is owned by the QWebPage but you can customize the look by changing its properties.

QWebPage also takes care of implementing the action, so that upon triggering the corresponding action is performed on the page.

### quint64 QWebPage::bytesReceived () const

Returns the number of bytes that were received from the network to render the current page.

### QString QWebPage::chooseFile ( QWebFrame * parentFrame, const QString & oldFile ) `[virtual protected]`

This function is called when the web content requests a file name, for example as a result of the user clicking on a "file upload" button in a HTML form.

### QWebPage * QWebPage::createModalDialog () `[virtual protected]`

This function is called whenever WebKit wants to create a new window that should act as a modal dialog.

### QObject * QWebPage::createPlugin ( const QString & classid, const QUrl & url, const QStringList & paramNames, const QStringList & paramValues ) `[virtual protected]`

This function is called whenever WebKit encounters a HTML object element with type "application/x-qt-plugin". The classid, url, paramNames and paramValues correspond to the HTML object element attributes and child elements to configure the embeddable object.

### QWebPage * QWebPage::createWindow () `[virtual protected]`

This function is called whenever WebKit wants to create a new window, for example as a result of a JavaScript request to open a document in a new window.

### QWebFrame * QWebPage::currentFrame () const

Returns the frame currently active.

### bool QWebPage::focusNextPrevChild ( bool next ) `[virtual]`

Similar to QWidget::focusNextPrevChild it focuses the next focusable web element if next is true. Otherwise the previous element is focused.

### void QWebPage::frameCreated ( QWebFrame * frame ) `[signal]`

This signal is emitted whenever the page creates a new frame.

### void QWebPage::geometryChangeRequest ( const QRect & geom ) `[signal]`

This signal is emitted whenever the document wants to change the position and size of the page to geom. This can happen for example through JavaScript.

### QWebHistory * QWebPage::history () const

Returns a pointer to the view's history of navigated web pages.

### void QWebPage::hoveringOverLink ( const QString & link, const QString & title, const QString & textContent = QString() ) `[signal]`

This signal is emitted when the mouse is hovering over a link. The first parameter is the link url, the second is the link title if any, and third textContent is the text content. Method is emitter with both empty parameters when the mouse isn't hovering over any link element.

### void QWebPage::javaScriptAlert ( QWebFrame * frame, const QString & msg ) `[virtual protected]`

This function is called whenever a JavaScript program calls the alert() function.

### bool QWebPage::javaScriptConfirm ( QWebFrame * frame, const QString & msg ) `[virtual protected]`

This function is called whenever a JavaScript program calls the confirm() function.

### void QWebPage::javaScriptConsoleMessage ( const QString & message, unsigned int lineNumber, const QString & sourceID ) `[virtual protected]`

This function is called whenever a JavaScript program tries to print to what is the console in web browsers.

### bool QWebPage::javaScriptPrompt ( QWebFrame * frame, const QString & msg, const QString & defaultValue, QString * result ) `[virtual protected]`

This function is called whenever a JavaScript program tries to prompt the user of input.

### void QWebPage::loadProgressChanged ( int progress ) `[signal]`

This signal is emitted when the global progress status changes. The current value is provided by progress in percent. It accumulates changes from all the child frames.

### QWebFrame * QWebPage::mainFrame () const

Returns the main frame of the page.

The main frame provides access to the hierarchy of sub-frames and is also needed if you want to explicitly render a web page into a given painter.

### NavigationRequestResponse QWebPage::navigationRequested ( QWebFrame * frame, const QWebNetworkRequest & request, NavigationType type ) `[virtual protected]`

### QWebNetworkInterface * QWebPage::networkInterface () const

See also setNetworkInterface().

### QNetworkProxy QWebPage::networkProxy () const

See also setNetworkProxy().

### void QWebPage::selectionChanged () `[signal]`

This signal is emitted whenever the selection changes.

### void QWebPage::setNetworkInterface ( QWebNetworkInterface * interface )

See also networkInterface().

### void QWebPage::setNetworkProxy ( const QNetworkProxy & proxy )

See also networkProxy().

### void QWebPage::setView ( QWidget * view )

Sets the view that is associated with the web page.

See also view().

### QWebSettings * QWebPage::settings ()

Returns a pointe to the page's settings object.

### void QWebPage::statusBarTextChanged ( const QString & text ) `[signal]`

This signal is emitted when the statusbar text is changed by the page.

### quint64 QWebPage::totalBytes () const

Returns the total number of bytes that were received from the network to render the current page, including extra content such as embedded images.

### void QWebPage::triggerAction ( WebAction action, bool checked = false ) `[virtual]`

This function can be called to trigger the specified action. It is also called by QtWebKit if the user triggers the action, for example through a context menu item.

If action is a checkable action then checked specified whether the action is toggled or not.

### QUndoStack * QWebPage::undoStack () const

Returns a pointer to the undo stack used for editable content.

### QString QWebPage::userAgentFor ( const QUrl & url ) const `[virtual protected]`

This function is called when a user agent for HTTP requests is needed. You can re-implement this function to dynamically return different user agent's for different urls, based on the url parameter.

### QWidget * QWebPage::view () const

Returns the view widget that is associated with the web page.

See also setView().