Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.webkit
Class QWebPage

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QObject
                      com.trolltech.qt.webkit.QWebPage

All Implemented Interfaces:
  QtJambiInterface

    public class QWebPage

extends QObject

The `QWebPage` class provides an object to view and edit web documents. `QWebPage` holds a main frame responsible for web content, settings, the history of navigated links and actions. This class can be used, together with `QWebFrame`, to provide functionality like `QWebView` in a widget-less environment.

`QWebPage`'s API is very similar to `QWebView`, as you are still provided with common functions like `action()` (known as `pageAction()` in `QWebView`), `triggerAction()`, `findText()` and `settings()`. More `QWebView`-like functions can be found in the main frame of `QWebPage`, obtained via `QWebPage::mainFrame()`. For example, the load(), setUrl() and setHtml() unctions for `QWebPage` can be accessed using `QWebFrame`.

The `loadStarted()` signal is emitted when the page begins to load.The `loadProgress()` signal, on the other hand, is emitted whenever an element of the web page completes loading, such as an embedded image, a script, etc. Finally, the `loadFinished()` signal is emitted when the page has loaded completely. Its argument, either true or false, indicates whether or not the load operation succeeded.

## Using QWebPage in a Widget-less Environment

Before you begin painting a `QWebPage` object, you need to set the size of the viewport by calling `setViewportSize()`. Then, you invoke the main frame's render function (`QWebFrame::render()`). An example of this is shown in the code snippet below.

Suppose we have a `Thumbnail` class as follows:

    class Thumbnailer extends QObject
    {
        public Signal0 finished = new Signal0();

        public Thumbnailer(QUrl url) { ... }

        private void render(Boolean b) { ... }

        private QWebPage page;

    }

The `Thumbnail`'s constructor takes in a `url`. We connect our `QWebPage` object's `loadFinished()` signal to our private slot, `render()`.

        public Thumbnailer(QUrl url)
        {
            page.mainFrame().load(url);
            page.loadFinished.connect(this, "render(Boolean)");
        }

The `render()` function shows how we can paint a thumbnail using a `QWebPage` object.

        void render(Boolean b)
        {
            page.setViewportSize(page.mainFrame().contentsSize());
            QImage image = new QImage(page.viewportSize(), QImage.Format.Format_ARGB32);
            QPainter painter = new QPainter(image);

            page.mainFrame().render(painter);
            painter.end();

            QImage thumbnail = image.scaled(400, 400);
            thumbnail.save("thumbnail.png");

            finished.emit();
        }

We begin by setting the `viewportSize` and then we instantiate a `QImage` object, `image`, with the same size as our `viewportSize`. This image is then sent as a parameter to `painter`. Next, we render the contents of the main frame and its subframes into `painter`. Finally, we save the scaled image.

See also:
  `QWebFrame`.

Nested Class Summary
`static class` | `QWebPage.FindFlag` This enum describes the options available to `QWebPage`'s `findText()` function.
`static class` | `QWebPage.FindFlags` This is a flags class for com.trolltech.qt.webkit.QWebPage.FindFlag
`static class` | `QWebPage.LinkDelegationPolicy` This enum defines the delegation policies a webpage can have when activating links and emitting the `linkClicked()` signal.
`static class` | `QWebPage.NavigationType` This enum describes the types of navigation available when browsing through hyperlinked documents.
`static class` | `QWebPage.WebAction`
`static class` | `QWebPage.WebWindowType`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary
`QSignalEmitter.Signal1` | `downloadRequested` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `frameCreated` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `geometryChangeRequested` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `linkClicked` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal3` | `linkHovered` This signal takes 3 generic argument(s).
`QSignalEmitter.Signal1` | `loadFinished` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `loadProgress` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal0` | `loadStarted` This signal is emitted when a new load of the page is started.
`QSignalEmitter.Signal1` | `menuBarVisibilityChangeRequested` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal0` | `microFocusChanged` This signal is emitted when for example the position of the cursor in an editable form element changes.
`QSignalEmitter.Signal1` | `printRequested` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `repaintRequested` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal3` | `scrollRequested` This signal takes 3 generic argument(s).
`QSignalEmitter.Signal0` | `selectionChanged` This signal is emitted whenever the selection changes.
`QSignalEmitter.Signal1` | `statusBarMessage` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `statusBarVisibilityChangeRequested` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `toolBarVisibilityChangeRequested` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `unsupportedContent` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal0` | `windowCloseRequested` This signal is emitted whenever the page requests the web browser window to be closed, for example through the JavaScript `window.close()` call.

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QWebPage()` Constructs an empty `QWebView` with parent `parent`.
`QWebPage(QObject parent)` Constructs an empty `QWebView` with parent `parent`.

Method Summary
`protected boolean` | `acceptNavigationRequest(QWebFrame frame, QNetworkRequest request, QWebPage.NavigationType type)` This function is called whenever `WebKit` requests to navigate `frame` to the resource specified by `request` by means of the specified navigation type `type`.
`QAction` | `action(QWebPage.WebAction action)` Returns a `QAction` for the specified `WebAction` `action`.
`long` | `bytesReceived()` Returns the number of bytes that were received from the network to render the current page.
`protected java.lang.String` | `chooseFile(QWebFrame originatingFrame, java.lang.String oldFile)` 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.
`protected QObject` | `createPlugin(java.lang.String classid, QUrl url, java.util.List paramNames, java.util.List paramValues)` This function is called whenever WebKit encounters a HTML object element with type "application/x-qt-plugin".
`protected QWebPage` | `createWindow(QWebPage.WebWindowType type)` 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.
`QWebFrame` | `currentFrame()` Returns the frame currently active.
`boolean` | `findText(java.lang.String subString)` Finds the next occurrence of the string, `subString`, in the page, using the given `options`.
`boolean` | `findText(java.lang.String subString, QWebPage.FindFlag[] options)` Finds the next occurrence of the string, `subString`, in the page, using the given `options`.
`boolean` | `findText(java.lang.String subString, QWebPage.FindFlags options)` Finds the next occurrence of the string, `subString`, in the page, using the given `options`.
`boolean` | `focusNextPrevChild(boolean next)` Similar to QWidget.:focusNextPrevChild it focuses the next focusable web element if `next` is true; otherwise the previous element is focused.
`boolean` | `forwardUnsupportedContent()` This property holds whether `QWebPage` should forward unsupported content through the unsupportedContent signal.
`QWebHistory` | `history()` Returns a pointer to the view's history of navigated web pages.
`java.lang.Object` | `inputMethodQuery(Qt.InputMethodQuery property)` 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.
`boolean` | `isModified()` This property holds whether the page contains unsubmitted form data.
`protected void` | `javaScriptAlert(QWebFrame originatingFrame, java.lang.String msg)` This function is called whenever a JavaScript program running inside `frame` calls the alert() function with the message `msg`.
`protected boolean` | `javaScriptConfirm(QWebFrame originatingFrame, java.lang.String msg)` This function is called whenever a JavaScript program running inside `frame` calls the confirm() function with the message, `msg`.
`protected void` | `javaScriptConsoleMessage(java.lang.String message, int lineNumber, java.lang.String sourceID)` This function is called whenever a JavaScript program tries to print a `message` to the web browser's console.
`protected java.lang.String` | `javaScriptPrompt(QWebFrame originatingFrame, java.lang.String msg, java.lang.String defaultValue)` This function is called whenever a `JavaScript` program running inside `frame` tries to prompt the user for input.
`QWebPage.LinkDelegationPolicy` | `linkDelegationPolicy()` This property holds how `QWebPage` should delegate the handling of links through the `linkClicked()` signal.
`QWebFrame` | `mainFrame()` Returns the main frame of the page.
`QNetworkAccessManager` | `networkAccessManager()` Returns the `QNetworkAccessManager` that is responsible for serving network requests for this `QWebPage`.
`QPalette` | `palette()` This property holds the page's palette.
`java.lang.String` | `selectedText()` This property holds the text currently selected.
`void` | `setForwardUnsupportedContent(boolean forward)` This property holds whether `QWebPage` should forward unsupported content through the unsupportedContent signal.
`void` | `setLinkDelegationPolicy(QWebPage.LinkDelegationPolicy policy)` This property holds how `QWebPage` should delegate the handling of links through the `linkClicked()` signal.
`void` | `setNetworkAccessManager(QNetworkAccessManager manager)` Sets the `QNetworkAccessManager` `manager` responsible for serving network requests for this `QWebPage`.
`void` | `setPalette(QPalette palette)` This property holds the page's palette.
`QWebSettings` | `settings()` Returns a pointer to the page's settings object.
`void` | `setView(QWidget view)` Sets the `view` that is associated with the web page.
`void` | `setViewportSize(QSize size)` This property holds the size of the viewport.
`boolean` | `swallowContextMenuEvent(QContextMenuEvent event)` Filters the context menu event, `event`, through handlers for scrollbars and custom event handlers in the web page.
`long` | `totalBytes()` 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` | `triggerAction(QWebPage.WebAction action)` This function can be called to trigger the specified `action`.
`void` | `triggerAction(QWebPage.WebAction action, boolean checked)` This function can be called to trigger the specified `action`.
`QUndoStack` | `undoStack()` Returns a pointer to the undo stack used for editable content.
`void` | `updatePositionDependentActions(QPoint pos)` Updates the page's actions depending on the position `pos`.
`protected java.lang.String` | `userAgentForUrl(QUrl url)` This function is called when a user agent for HTTP requests is needed.
`QWidget` | `view()` Returns the view widget that is associated with the web page.
`QSize` | `viewportSize()` This property holds the size of the viewport.

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Field Detail

### downloadRequested

    public final QSignalEmitter.Signal1 downloadRequested

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.network.QNetworkRequest(named: request)>:

  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`.

See also:
  `unsupportedContent()` .

### frameCreated

    public final QSignalEmitter.Signal1 frameCreated

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.webkit.QWebFrame(named: frame)>:

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

### geometryChangeRequested

    public final QSignalEmitter.Signal1 geometryChangeRequested

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QRect(named: geom)>:

  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.

### linkClicked

    public final QSignalEmitter.Signal1 linkClicked

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QUrl(named: url)>:

  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.

See also:
  `linkHovered()` .

### linkHovered

    public final QSignalEmitter.Signal3 linkHovered

  This signal takes 3 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: link), java.lang.String(named: title), java.lang.String(named: textContent)>:

  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.

See also:
  `linkClicked()` .

### loadFinished

    public final QSignalEmitter.Signal1 loadFinished

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Boolean(named: ok)>:

  This signal is emitted when a load of the page is finished. `ok` will indicate whether the load was successful or any error occurred.

See also:
  `loadStarted()` .

### loadProgress

    public final QSignalEmitter.Signal1 loadProgress

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: progress)>:

  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.

See also:
  `bytesReceived()`.

### loadStarted

    public final QSignalEmitter.Signal0 loadStarted

  This signal is emitted when a new load of the page is started.

See also:
  `loadFinished()` .

### menuBarVisibilityChangeRequested

    public final QSignalEmitter.Signal1 menuBarVisibilityChangeRequested

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Boolean(named: visible)>:

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

### microFocusChanged

    public final QSignalEmitter.Signal0 microFocusChanged

  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.

### printRequested

    public final QSignalEmitter.Signal1 printRequested

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.webkit.QWebFrame(named: frame)>:

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

See also:
  `QWebFrame::print()`, and `QPrintPreviewDialog`.

### repaintRequested

    public final QSignalEmitter.Signal1 repaintRequested

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QRect(named: dirtyRect)>:

  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()`.

### scrollRequested

    public final QSignalEmitter.Signal3 scrollRequested

  This signal takes 3 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: dx), java.lang.Integer(named: dy), com.trolltech.qt.core.QRect(named: rectToScroll)>:

  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()`.

### selectionChanged

    public final QSignalEmitter.Signal0 selectionChanged

  This signal is emitted whenever the selection changes.

See also:
  `selectedText()`.

### statusBarMessage

    public final QSignalEmitter.Signal1 statusBarMessage

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: text)>:

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

### statusBarVisibilityChangeRequested

    public final QSignalEmitter.Signal1 statusBarVisibilityChangeRequested

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Boolean(named: visible)>:

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

### toolBarVisibilityChangeRequested

    public final QSignalEmitter.Signal1 toolBarVisibilityChangeRequested

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Boolean(named: visible)>:

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

### unsupportedContent

    public final QSignalEmitter.Signal1 unsupportedContent

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.network.QNetworkReply(named: reply)>:

  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.

See also:
  `downloadRequested()` .

### windowCloseRequested

    public final QSignalEmitter.Signal0 windowCloseRequested

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

Constructor Detail

### QWebPage

    public QWebPage()

  Constructs an empty `QWebView` with parent `parent`.

### QWebPage

    public QWebPage(QObject parent)

  Constructs an empty `QWebView` with parent `parent`.

Method Detail

### action

    public final QAction action(QWebPage.WebAction action)

  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.

See also:
  `triggerAction()`.

### bytesReceived

    public final long bytesReceived()

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

See also:
  `totalBytes()`.

### currentFrame

    public final QWebFrame currentFrame()

  Returns the frame currently active.

See also:
  `mainFrame()`, and `frameCreated()` .

### findText

    public final boolean findText(java.lang.String subString,
                                  QWebPage.FindFlag[] options)

  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.

### findText

    public final boolean findText(java.lang.String subString)

  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.

### findText

    public final boolean findText(java.lang.String subString,
                                  QWebPage.FindFlags options)

  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.

### focusNextPrevChild

    public final boolean focusNextPrevChild(boolean 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.

### forwardUnsupportedContent

    public final boolean forwardUnsupportedContent()

  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.

### history

    public final QWebHistory history()

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

### inputMethodQuery

    public final java.lang.Object inputMethodQuery(Qt.InputMethodQuery property)

  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`.

### isModified

    public final boolean isModified()

  This property holds whether the page contains unsubmitted form data.

### linkDelegationPolicy

    public final QWebPage.LinkDelegationPolicy linkDelegationPolicy()

  This property holds how `QWebPage` should delegate the handling of links through the `linkClicked()` signal. The default is to delegate no links.

### mainFrame

    public final QWebFrame mainFrame()

  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.

See also:
  `currentFrame()`.

### networkAccessManager

    public final QNetworkAccessManager networkAccessManager()

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

See also:
  `setNetworkAccessManager()`.

### palette

    public final QPalette palette()

  This property holds the page's palette. The background brush of the palette is used to draw the background of the main frame.

### selectedText

    public final java.lang.String selectedText()

  This property holds the text currently selected.

See also:
  `selectionChanged()` .

### setForwardUnsupportedContent

    public final void setForwardUnsupportedContent(boolean forward)

  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.

### setLinkDelegationPolicy

    public final void setLinkDelegationPolicy(QWebPage.LinkDelegationPolicy policy)

  This property holds how `QWebPage` should delegate the handling of links through the `linkClicked()` signal. The default is to delegate no links.

### setNetworkAccessManager

    public final void setNetworkAccessManager(QNetworkAccessManager manager)

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

See also:
  `networkAccessManager()`.

### setPalette

    public final void setPalette(QPalette palette)

  This property holds the page's palette. The background brush of the palette is used to draw the background of the main frame.

### setView

    public final void setView(QWidget view)

  Sets the `view` that is associated with the web page.

See also:
  `view()`.

### setViewportSize

    public final void setViewportSize(QSize size)

  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.

### settings

    public final QWebSettings settings()

  Returns a pointer to the page's settings object.

See also:
  `QWebSettings::globalSettings()`.

### swallowContextMenuEvent

    public final boolean swallowContextMenuEvent(QContextMenuEvent event)

  Filters the context menu event, `event`, through handlers for scrollbars and custom event handlers in the web page. Returns true if the event was handled; otherwise false.

  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.

### totalBytes

    public final long totalBytes()

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

See also:
  `bytesReceived()`.

### undoStack

    public final QUndoStack undoStack()

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

### updatePositionDependentActions

    public final void updatePositionDependentActions(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.

### view

    public final QWidget view()

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

See also:
  `setView()`.

### viewportSize

    public final QSize viewportSize()

  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.

### acceptNavigationRequest

    protected boolean acceptNavigationRequest(QWebFrame frame,
                                              QNetworkRequest request,
                                              QWebPage.NavigationType type)

  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.

### chooseFile

    protected java.lang.String chooseFile(QWebFrame originatingFrame,
                                          java.lang.String oldFile)

  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`.

### createPlugin

    protected QObject createPlugin(java.lang.String classid,
                                   QUrl url,
                                   java.util.List paramNames,
                                   java.util.List paramValues)

  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.

### createWindow

    protected QWebPage createWindow(QWebPage.WebWindowType type)

  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.

See also:
  `acceptNavigationRequest()`.

### javaScriptAlert

    protected void javaScriptAlert(QWebFrame originatingFrame,
                                   java.lang.String msg)

  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.

### javaScriptConfirm

    protected boolean javaScriptConfirm(QWebFrame originatingFrame,
                                        java.lang.String msg)

  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.

### javaScriptConsoleMessage

    protected void javaScriptConsoleMessage(java.lang.String message,
                                            int lineNumber,
                                            java.lang.String sourceID)

  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.

### triggerAction

    public final void triggerAction(QWebPage.WebAction action)

  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.

See also:
  `action()`.

### triggerAction

    public void triggerAction(QWebPage.WebAction action,
                              boolean checked)

  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.

See also:
  `action()`.

### userAgentForUrl

    protected java.lang.String userAgentForUrl(QUrl url)

  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:

  - %Platform% and %Subplatform% are expanded to the windowing system and the operation system.
  - %Security% expands to U if SSL is enabled, otherwise N. SSL is enabled if QSslSocket::supportsSsl() returns true.
  - %Locale% is replaced with `QLocale::name()`.
  - %WebKitVersion% currently expands to 523.15
  - %AppVersion% expands to `QCoreApplication::applicationName()`/`QCoreApplication::applicationVersion()` if they're set; otherwise defaulting to Qt and the current Qt version.

### javaScriptPrompt

    protected java.lang.String javaScriptPrompt(QWebFrame originatingFrame,
                                                java.lang.String msg,
                                                java.lang.String defaultValue)

  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`.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD