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

QWebPage Class Reference
[QtWebKit module]

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.

Public Types

Properties

Public Functions

Signals

Protected Functions

Additional Inherited Members


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::Extension

This enum describes the types of extensions that the page can support. Before using these extensions, you should verify that the extension is supported by calling supportsExtension().

Currently there are no extensions.

enum QWebPage::FindFlag
flags QWebPage::FindFlags

This enum describes the options available to QWebPage's findText() function. The options can be OR-ed together from the following list:

ConstantValueDescription
QWebPage::FindBackward1Searches backwards instead of forwards.
QWebPage::FindCaseSensitively2By default findText() works case insensitive. Specifying this option changes the behaviour to a case sensitive find operation.
QWebPage::FindWrapsAroundDocument4Makes findText() restart from the beginning of the document if the end was reached and the text was not found.

The FindFlags type is a typedef for QFlags<FindFlag>. It stores an OR combination of FindFlag values.

enum QWebPage::LinkDelegationPolicy

This enum defines the delegation policies a webpage can have when activating links and emitting the linkClicked() signal.

ConstantValueDescription
QWebPage::DontDelegateLinks0No links are delegated. Instead, QWebPage tries to handle them all.
QWebPage::DelegateExternalLinks1When activating links that point to documents not stored on the local filesystem or an equivalent - such as the Qt resource system - then linkClicked() is emitted.
QWebPage::DelegateAllLinks2Whenever a link is activated the linkClicked() signal is emitted.

enum QWebPage::NavigationType

This enum describes the types of navigation available when browsing through hyperlinked documents.

ConstantValueDescription
QWebPage::NavigationTypeLinkClicked0The user clicked on a link or pressed return on a focused link.
QWebPage::NavigationTypeFormSubmitted1The user activated a submit button for an HTML form.
QWebPage::NavigationTypeBackOrForward2Navigation to a previously shown document in the back or forward history is requested.
QWebPage::NavigationTypeReload3The user activated the reload action.
QWebPage::NavigationTypeFormResubmitted4An HTML form was submitted a second time.
QWebPage::NavigationTypeOther5A navigation to another document using a method not listed above.

enum QWebPage::WebAction

ConstantValueDescription
QWebPage::NoWebAction-1No action is triggered.
QWebPage::OpenLink0Open the current link.
QWebPage::OpenLinkInNewWindow1Open the current link in a new window.
QWebPage::OpenFrameInNewWindow2Replicate the current frame in a new window.
QWebPage::DownloadLinkToDisk3Download the current link to the disk.
QWebPage::CopyLinkToClipboard4Copy the current link to the clipboard.
QWebPage::OpenImageInNewWindow5Open the highlighted image in a new window.
QWebPage::DownloadImageToDisk6Download the highlighted image to the disk.
QWebPage::CopyImageToClipboard7Copy the highlighted image to the clipboard.
QWebPage::Back8Navigate back in the history of navigated links.
QWebPage::Forward9Navigate forward in the history of navigated links.
QWebPage::Stop10Stop loading the current page.
QWebPage::Reload11Reload the current page.
QWebPage::Cut12Cut the content currently selected into the clipboard.
QWebPage::Copy13Copy the content currently selected into the clipboard.
QWebPage::Paste14Paste content from the clipboard.
QWebPage::Undo15Undo the last editing action.
QWebPage::Redo16Redo the last editing action.
QWebPage::MoveToNextChar17Move the cursor to the next character.
QWebPage::MoveToPreviousChar18Move the cursor to the previous character.
QWebPage::MoveToNextWord19Move the cursor to the next word.
QWebPage::MoveToPreviousWord20Move the cursor to the previous word.
QWebPage::MoveToNextLine21Move the cursor to the next line.
QWebPage::MoveToPreviousLine22Move the cursor to the previous line.
QWebPage::MoveToStartOfLine23Move the cursor to the start of the line.
QWebPage::MoveToEndOfLine24Move the cursor to the end of the line.
QWebPage::MoveToStartOfBlock25Move the cursor to the start of the block.
QWebPage::MoveToEndOfBlock26Move the cursor to the end of the block.
QWebPage::MoveToStartOfDocument27Move the cursor to the start of the document.
QWebPage::MoveToEndOfDocument28Move the cursor to the end of the document.
QWebPage::SelectNextChar29Select to the next character.
QWebPage::SelectPreviousChar30Select to the previous character.
QWebPage::SelectNextWord31Select to the next word.
QWebPage::SelectPreviousWord32Select to the previous word.
QWebPage::SelectNextLine33Select to the next line.
QWebPage::SelectPreviousLine34Select to the previous line.
QWebPage::SelectStartOfLine35Select to the start of the line.
QWebPage::SelectEndOfLine36Select to the end of the line.
QWebPage::SelectStartOfBlock37Select to the start of the block.
QWebPage::SelectEndOfBlock38Select to the end of the block.
QWebPage::SelectStartOfDocument39Select to the start of the document.
QWebPage::SelectEndOfDocument40Select to the end of the document.
QWebPage::DeleteStartOfWord41Delete to the start of the word.
QWebPage::DeleteEndOfWord42Delete to the end of the word.
QWebPage::SetTextDirectionDefault43Set the text direction to the default direction.
QWebPage::SetTextDirectionLeftToRight44Set the text direction to left-to-right.
QWebPage::SetTextDirectionRightToLeft45Set the text direction to right-to-left.
QWebPage::ToggleBold46Toggle the formatting between bold and normal weight.
QWebPage::ToggleItalic47Toggle the formatting between italic and normal style.
QWebPage::ToggleUnderline48Toggle underlining.
QWebPage::InspectElement49Show the Web Inspector with the currently highlighted HTML element.

enum QWebPage::WebWindowType

ConstantValueDescription
QWebPage::WebBrowserWindow0The window is a regular web browser window.
QWebPage::WebModalDialog1The window acts as modal dialog.


Property Documentation

forwardUnsupportedContent : bool

This property holds whether QWebPage should forward unsupported content through the unsupportedContent signal.

If disabled the download of such content is aborted immediately.

By default unsupported content is not forwarded.

Access functions:

linkDelegationPolicy : LinkDelegationPolicy

This property holds how QWebPage should delegate the handling of links through the linkClicked() signal.

The default is to delegate no links.

Access functions:

modified : const bool

This property holds whether the page contains unsubmitted form data.

Access functions:

palette : QPalette

This property holds the page's palette.

The background brush of the palette is used to draw the background of the main frame.

Access functions:

selectedText : const QString

This property holds the text currently selected.

Access functions:

viewportSize : QSize

This property holds the size of the viewport.

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

Access functions:


Member Function Documentation

QWebPage::QWebPage ( QObject * parent = 0 )

Constructs an empty QWebView with parent parent.

QWebPage::~QWebPage ()

Destructor.

bool QWebPage::acceptNavigationRequest ( QWebFrame * frame, const QWebNetworkRequest & request, NavigationType type )   [virtual protected]

This function is called whenever WebKit requests to navigate frame to the resource specified by request by means of the specified navigation type type.

The default implementation interprets the page's linkDelegationPolicy and emits linkClicked accordingly or returns true to let QWebPage handle the navigation itself.

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 & suggestedFile )   [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.

A suggested filename may be provided in suggestedFile. The frame originating the request is provided as parentFrame.

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 ( WebWindowType type )   [virtual protected]

This function is called whenever WebKit wants to create a new window of the given type, for example when a JavaScript program requests to open a document in a new window.

If the new window can be created, the new window's QWebPage is returned; otherwise a null pointer is returned.

If the view associated with the web page is a QWebView object, then the default implementation forwards the request to QWebView's createWindow() function; otherwise it returns a null pointer.

QWebFrame * QWebPage::currentFrame () const

Returns the frame currently active.

void QWebPage::downloadRequested ( const QNetworkRequest & request )   [signal]

This signal is emitted when the user decides to download a link. The url of the link as well as additional meta-information is contained in request.

bool QWebPage::extension ( Extension extension, const ExtensionOption * option = 0, ExtensionReturn * output = 0 )   [virtual]

This virtual function can be reimplemented in a QWebPage subclass to provide support for extensions. The option argument is provided as input to the extension; the output results can be stored in output.

The behavior of this function is determined by extension.

You can call supportsExtension() to check if an extension is supported by the page.

By default, no extensions are supported, and this function returns false.

See also supportsExtension() and Extension.

bool QWebPage::findText ( const QString & subString, FindFlags options = 0 )

Finds the next occurrence of the string, subString, in the page, using the given options. Returns true of subString was found and selects the match visually; otherwise returns false.

bool QWebPage::focusNextPrevChild ( bool next )

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

Returns true if it can find a new focusable element, or false if it can't.

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

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

void QWebPage::geometryChangeRequested ( 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.

QVariant QWebPage::inputMethodQuery ( Qt::InputMethodQuery property ) const

This method is used by the input method to query a set of properties of the page to be able to support complex input method operations as support for surrounding text and reconversions.

property specifies which property is queried.

See also QWidget::inputMethodEvent(), QInputMethodEvent, and QInputContext.

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

This function is called whenever a JavaScript program running inside frame calls the alert() function with the message msg.

The default implementation shows the message, msg, with QMessageBox::information.

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

This function is called whenever a JavaScript program running inside frame calls the confirm() function with the message, msg. Returns true if the user confirms the message; otherwise returns false.

The default implementation executes the query using QMessageBox::information with QMessageBox::Yes and QMessageBox::No buttons.

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

This function is called whenever a JavaScript program tries to print a message to the web browser's console.

For example in case of evaluation errors the source URL may be provided in sourceID as well as the lineNumber.

The default implementation prints nothing.

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

This function is called whenever a JavaScript program running inside frame tries to prompt the user for input. The program may provide an optional message, msg, as well as a default value for the input in defaultValue.

If the prompt was cancelled by the user the implementation should return false; otherwise the result should be written to result and true should be returned.

The default implementation uses QInputDialog::getText.

void QWebPage::linkClicked ( const QUrl & url )   [signal]

This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy property is set to delegate the link handling for the specified url.

By default no links are delegated and are handled by QWebPage instead.

void QWebPage::linkHovered ( const QString & link, const QString & title, const QString & textContent )   [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::loadProgress ( int progress )   [signal]

This signal is emitted when the global progress status changes. The current value is provided by progress and scales from 0 to 100, which is the default range of QProgressBar. 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.

void QWebPage::menuBarVisibilityChangeRequested ( bool visible )   [signal]

This signal is emitted whenever the visibility of the menubar in a web browser window that hosts QWebPage should be changed to visible.

void QWebPage::microFocusChanged ()   [signal]

This signal is emitted when for example the position of the cursor in an editable form element changes. It is used inform input methods about the new on-screen position where the user is able to enter text. This signal is usually connected to QWidget's updateMicroFocus() slot.

QNetworkAccessManager * QWebPage::networkAccessManager () const

Returns the QNetworkAccessManager that is responsible for serving network requests for this QWebPage.

See also setNetworkAccessManager().

QWebPluginFactory * QWebPage::pluginFactory () const

Returns the QWebPluginFactory that is responsible for creating plugins embedded into this QWebPage. If no plugin factory is installed a null pointer is returned.

See also setPluginFactory().

void QWebPage::printRequested ( QWebFrame * frame )   [signal]

This signal is emitted whenever the page requests the web browser to print frame, for example through the JavaScript window.print() call.

void QWebPage::repaintRequested ( const QRect & dirtyRect )   [signal]

This signal is emitted whenever this QWebPage should be updated and no view was set. dirtyRect contains the area that needs to be updated. To paint the QWebPage get the mainFrame() and call the render(QPainter*, const QRegion&) method with the dirtyRect as the second parameter.

See also mainFrame() and view().

void QWebPage::scrollRequested ( int dx, int dy, const QRect & rectToScroll )   [signal]

This signal is emitted whenever the content given by rectToScroll needs to be scrolled dx and dy downwards and no view was set.

See also view().

void QWebPage::selectionChanged ()   [signal]

This signal is emitted whenever the selection changes.

void QWebPage::setNetworkAccessManager ( QNetworkAccessManager * manager )

Sets the QNetworkAccessManager manager responsible for serving network requests for this QWebPage.

See also networkAccessManager().

void QWebPage::setPluginFactory ( QWebPluginFactory * factory )

Sets the QWebPluginFactory factory responsible for creating plugins embedded into this QWebPage.

See also pluginFactory().

void QWebPage::setView ( QWidget * view )

Sets the view that is associated with the web page.

See also view().

QWebSettings * QWebPage::settings () const

Returns a pointer to the page's settings object.

void QWebPage::statusBarMessage ( const QString & text )   [signal]

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

void QWebPage::statusBarVisibilityChangeRequested ( bool visible )   [signal]

This signal is emitted whenever the visibility of the statusbar in a web browser window that hosts QWebPage should be changed to visible.

bool QWebPage::supportsExtension ( Extension extension ) const   [virtual]

This virtual function returns true if the web page supports extension; otherwise false is returned.

See also extension().

bool QWebPage::swallowContextMenuEvent ( QContextMenuEvent * event )

Passes the context menu event, event, to the currently displayed webpage and returns true if the page handled the event; otherwise false is returned.

A web page may swallow a context menu event through a custom event handler, allowing for context menus to be implemented in HTML/JavaScript. This is used by Google Maps, for example.

void QWebPage::toolBarVisibilityChangeRequested ( bool visible )   [signal]

This signal is emitted whenever the visibility of the toolbar in a web browser window that hosts QWebPage should be changed to visible.

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.

void QWebPage::unsupportedContent ( QNetworkReply * reply )   [signal]

This signals is emitted when webkit cannot handle a link the user navigated to.

At signal emissions time the meta data of the QNetworkReply reply is available.

Note: This signal is only emitted if the forwardUnsupportedContent property is set to true.

void QWebPage::updatePositionDependentActions ( const QPoint & pos )

Updates the page's actions depending on the position pos. For example if pos is over an image element the CopyImageToClipboard action is enabled.

QString QWebPage::userAgentForUrl ( 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.

The default implementation returns the following value:

"Mozilla/5.0 (%Platform%; %Security%; %Subplatform%; %Locale%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko, Safari/419.3) %AppVersion"

In this string the following values are replaced at run-time:

QWidget * QWebPage::view () const

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

See also setView().

void QWebPage::windowCloseRequested ()   [signal]

This signal is emitted whenever the page requests the web browser window to be closed, for example through the JavaScript window.close() call.


Copyright © 2008 Trolltech Trademarks
Qt 4.4.0-rc1