Qt 5.11 | Qt WebEngine | C++ Classes | QWebEnginePage

Qt 5.11.3 Reference Documentation

# QWebEnginePage Class

The QWebEnginePage class provides an object to view and edit web documents. More...

Header: | #include <QWebEnginePage>
qmake: | QT += webenginewidgets
Since: | Qt 5.4

- List of all members, including inherited members

## Public Types

enum | Feature { Geolocation, MediaAudioCapture, MediaVideoCapture, MediaAudioVideoCapture, ..., DesktopAudioVideoCapture }
enum | FileSelectionMode { FileSelectOpen, FileSelectOpenMultiple }
enum | FindFlag { FindBackward, FindCaseSensitively }
flags | FindFlags
enum | JavaScriptConsoleMessageLevel { InfoMessageLevel, WarningMessageLevel, ErrorMessageLevel }
enum | NavigationType { NavigationTypeLinkClicked, NavigationTypeTyped, NavigationTypeFormSubmitted, NavigationTypeBackForward, NavigationTypeReload, NavigationTypeOther }
enum | PermissionPolicy { PermissionUnknown, PermissionGrantedByUser, PermissionDeniedByUser }
enum | RenderProcessTerminationStatus { NormalTerminationStatus, AbnormalTerminationStatus, CrashedTerminationStatus, KilledTerminationStatus }
enum | WebAction { NoWebAction, Back, Forward, Stop, ..., InsertUnorderedList }
enum | WebWindowType { WebBrowserWindow, WebBrowserTab, WebDialog, WebBrowserBackgroundTab }

## Properties

- audioMuted : bool
- backgroundColor : QColor
- contentsSize : const QSizeF
- hasSelection : const bool
- icon : const QIcon
- iconUrl : const QUrl
- recentlyAudible : const bool

- requestedUrl : const QUrl
- scrollPosition : const QPointF
- selectedText : const QString
- title : const QString
- url : QUrl
- zoomFactor : qreal

## Public Functions

| QWebEnginePage(QObject *parent = Q_NULLPTR)
| QWebEnginePage(QWebEngineProfile *profile, QObject *parent = Q_NULLPTR)
virtual | ~QWebEnginePage()
QAction * | action(QWebEnginePage::WebAction action) const
QColor | backgroundColor() const
QSizeF | contentsSize() const
const QWebEngineContextMenuData & | contextMenuData() const
QMenu * | createStandardContextMenu()
QWebEnginePage * | devToolsPage() const
void | download(const QUrl &url, const QString &filename = QString())
void | findText(const QString &subString, QWebEnginePage::FindFlags options = FindFlags(), const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>())
bool | hasSelection() const
QWebEngineHistory * | history() const
QIcon | icon() const
QUrl | iconUrl() const
QWebEnginePage * | inspectedPage() const
bool | isAudioMuted() const
void | load(const QUrl &url)
void | load(const QWebEngineHttpRequest &request)
void | print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback)
void | printToPdf(const QString &filePath, const QPageLayout &pageLayout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()))
void | printToPdf(const QWebEngineCallback<const QByteArray &> &resultCallback, const QPageLayout &pageLayout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()))
QWebEngineProfile * | profile() const
bool | recentlyAudible() const
void | replaceMisspelledWord(const QString &replacement)
QUrl | requestedUrl() const
void | runJavaScript(const QString &scriptSource)
void | runJavaScript(const QString &scriptSource, quint32 worldId)
void | runJavaScript(const QString &scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)
void | runJavaScript(const QString &scriptSource, quint32 worldId, const QWebEngineCallback<const QVariant &> &resultCallback)
void | save(const QString &filePath, QWebEngineDownloadItem::SavePageFormat format = QWebEngineDownloadItem::MimeHtmlSaveFormat) const
QWebEngineScriptCollection & | scripts()
QPointF | scrollPosition() const
QString | selectedText() const
void | setAudioMuted(bool muted)
void | setBackgroundColor(const QColor &color)
void | setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl())
void | setDevToolsPage(QWebEnginePage *devToolsPage)
void | setFeaturePermission(const QUrl &securityOrigin, QWebEnginePage::Feature feature, QWebEnginePage::PermissionPolicy policy)
void | setHtml(const QString &html, const QUrl &baseUrl = QUrl())
void | setInspectedPage(QWebEnginePage *page)
void | setUrl(const QUrl &url)
void | setView(QWidget *view)
void | setWebChannel(QWebChannel *channel, uint worldId)
void | setWebChannel(QWebChannel *channel)
void | setZoomFactor(qreal factor)
QWebEngineSettings * | settings() const
QString | title() const
void | toHtml(const QWebEngineCallback<const QString &> &resultCallback) const
void | toPlainText(const QWebEngineCallback<const QString &> &resultCallback) const
virtual void | triggerAction(QWebEnginePage::WebAction action, bool checked = false)
QUrl | url() const
QWidget * | view() const
QWebChannel * | webChannel() const
qreal | zoomFactor() const

## Reimplemented Public Functions

virtual bool | event(QEvent *e)

## Signals

void | audioMutedChanged(bool muted)
void | authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator)
void | contentsSizeChanged(const QSizeF &size)
void | featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature)
void | featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature)
void | fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest)
void | geometryChangeRequested(const QRect &geom)
void | iconChanged(const QIcon &icon)
void | iconUrlChanged(const QUrl &url)
void | linkHovered(const QString &url)
void | loadFinished(bool ok)
void | loadProgress(int progress)
void | loadStarted()
void | pdfPrintingFinished(const QString &filePath, bool success)
void | proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost)
void | quotaRequested(QWebEngineQuotaRequest quotaRequest)
void | recentlyAudibleChanged(bool recentlyAudible)
void | registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request)
void | renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode)
void | scrollPositionChanged(const QPointF &position)
void | selectionChanged()
void | titleChanged(const QString &title)
void | urlChanged(const QUrl &url)
void | windowCloseRequested()

## Protected Functions

virtual bool | acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
virtual bool | certificateError(const QWebEngineCertificateError &certificateError)
virtual QStringList | chooseFiles(QWebEnginePage::FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes)
virtual QWebEnginePage * | createWindow(QWebEnginePage::WebWindowType type)
virtual void | javaScriptAlert(const QUrl &securityOrigin, const QString &msg)
virtual bool | javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)
virtual void | javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)
virtual bool | javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString *result)

## Detailed Description

The QWebEnginePage class provides an object to view and edit web documents.

A web engine page holds the contents of an HTML document, the history of navigated links, and actions.

QWebEnginePage's API is very similar to QWebEngineView, as you are still provided with common functions like action() (known as pageAction() in QWebEngineView), triggerAction(), and findText().

A page can be loaded using load() or setUrl(). Alternatively, if you have the HTML content readily available, you can use setHtml(). The GET method is always used to load URLs.

The QWebEnginePage class also offers methods to retrieve both the URL currently loaded by the page (see url()) as well as the URL originally requested to be loaded (see requestedUrl()). These methods make possible the retrieval of the URL before and after a DNS resolution or a redirection occurs during the load process. The requestedUrl() also matches to the URL added to the page history (QWebEngineHistory) if load is successful.

The title of an HTML page can be accessed with the title() property. Additionally, a page may also specify an icon, which can be accessed using the icon() or its URL using the iconUrl() property. If the title or the icon changes, the corresponding titleChanged(), iconChanged() and iconUrlChanged() signals will be emitted. The zoomFactor() property enables zooming the contents of the web page by a scale factor.

The loadStarted() signal is emitted when the page begins to load, whereas the loadProgress() signal is emitted whenever an element of the web page completes loading, such as an embedded image or a script. The loadFinished() signal is emitted when the page contents have been loaded completely, independent of script execution or page rendering. Its argument, either `true` or `false`, indicates whether or not the load operation succeeded.

An HTML document is loaded in a main frame within the web page. If it references child frames (as defined by the `<frame>` or `<iframe>` elements), they are considered part of the content. Child frames are individually accessible only through JavaScript.

Web sites define security origin for safely accessing each other's resources for client-side scripting or databases. An origin consist of a host name, a scheme, and a port number. For example, the sites `http://www.example.com/my/page.html` and `http://www.example.com/my/overview.html` are allowed to share the same database or access each other's documents when used in HTML frame sets and JavaScript. At the same time, `http://www.malicious.com/evil.html` is prevented from accessing the resources of `http://www.example.com/`, because they are of a different security origin. By default, local schemes like `file://` and `qrc://` are considered to be in the same security origin, and can access each other's resources. Local resources are by default restricted from accessing remote content, which means that `file://` will not be able to access `http://domain.com/foo.html`.

Scripts can be executed on the web page by using runJavaScript(), either in the main JavaScript world, along with the rest of the JavaScript coming from the web contents, or in their own isolated world. While the DOM of the page can be accessed from any world, JavaScript variables of a function defined in one world are not accessible from a different one. QWebEngineScript::ScriptWorldId provides some predefined IDs for this purpose. Using the `runJavaScript()` version without the world ID is the same as running the script in the `MainWorld`.

The FocusOnNavigationEnabled setting can be used to make the view associated with the page automatically receive focus when a navigation operation occurs (like loading or reloading a page or navigating through history).

## Member Type Documentation

### enum QWebEnginePage::Feature

This enum describes the platform feature access categories that the user may be asked to grant or deny access to:

Constant | Value | Description
--- | --- | ---
`QWebEnginePage::Geolocation` | `1` | Location hardware or service.
`QWebEnginePage::MediaAudioCapture` | `2` | Audio capture devices, such as microphones.
`QWebEnginePage::MediaVideoCapture` | `3` | Video devices, such as cameras.
`QWebEnginePage::MediaAudioVideoCapture` | `4` | Both audio and video capture devices.
`QWebEnginePage::MouseLock` | `5` | Mouse locking, which locks the mouse pointer to the web view and is typically used in games.
`QWebEnginePage::DesktopVideoCapture` | `6` | Video output capture, that is, the capture of the user's display, for screen sharing purposes for example. (Added in Qt 5.10)
`QWebEnginePage::DesktopAudioVideoCapture` | `7` | Both audio and video output capture. (Added in Qt 5.10)

See also featurePermissionRequested(), featurePermissionRequestCanceled(), setFeaturePermission(), and PermissionPolicy.

### enum QWebEnginePage::FileSelectionMode

This enum indicates whether the implementation of the chooseFiles() function should return only one file or may return multiple files:

Constant | Value | Description
--- | --- | ---
`QWebEnginePage::FileSelectOpen` | `0` | Return only one file name.
`QWebEnginePage::FileSelectOpenMultiple` | `1` | Return multiple file names.

See also chooseFiles().

### enum QWebEnginePage::FindFlag
flags QWebEnginePage::FindFlags

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

Constant | Value | Description
--- | --- | ---
`QWebEnginePage::FindBackward` | `1` | Searches backwards instead of forwards.
`QWebEnginePage::FindCaseSensitively` | `2` | By default findText() works case insensitive. Specifying this option changes the behavior to a case sensitive find operation.

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

### enum QWebEnginePage::JavaScriptConsoleMessageLevel

This enum describes the different severity levels a JavaScript console message can have:

Constant | Value | Description
--- | --- | ---
`QWebEnginePage::InfoMessageLevel` | `0` | The message is purely informative and can safely be ignored.
`QWebEnginePage::WarningMessageLevel` | `1` | The message informs about unexpected behavior or errors that may need attention.
`QWebEnginePage::ErrorMessageLevel` | `2` | The message indicates there has been an error.

### enum QWebEnginePage::NavigationType

This enum describes the type of a navigation request:

Constant | Value | Description
--- | --- | ---
`QWebEnginePage::NavigationTypeLinkClicked` | `0` | The navigation request resulted from a clicked link.
`QWebEnginePage::NavigationTypeTyped` | `1` | The navigation request resulted from an explicitly loaded URL.
`QWebEnginePage::NavigationTypeFormSubmitted` | `2` | The navigation request resulted from a form submission.
`QWebEnginePage::NavigationTypeBackForward` | `3` | The navigation request resulted from a back or forward action.
`QWebEnginePage::NavigationTypeReload` | `4` | The navigation request resulted from a reload action.
`QWebEnginePage::NavigationTypeOther` | `5` | The navigation request was triggered by other means not covered by the above.

See also acceptNavigationRequest().

### enum QWebEnginePage::PermissionPolicy

This enum describes the permission policies that the user may set for data or device access:

Constant | Value | Description
--- | --- | ---
`QWebEnginePage::PermissionUnknown` | `0` | It is unknown whether the user grants or denies permission.
`QWebEnginePage::PermissionGrantedByUser` | `1` | The user has granted permission.
`QWebEnginePage::PermissionDeniedByUser` | `2` | The user has denied permission.

See also featurePermissionRequested(), featurePermissionRequestCanceled(), setFeaturePermission(), and Feature.

### enum QWebEnginePage::RenderProcessTerminationStatus

This enum describes the status with which the render process terminated:

Constant | Value | Description
--- | --- | ---
`QWebEnginePage::NormalTerminationStatus` | `0` | The render process terminated normally.
`QWebEnginePage::AbnormalTerminationStatus` | `1` | The render process terminated with with a non-zero exit status.
`QWebEnginePage::CrashedTerminationStatus` | `2` | The render process crashed, for example because of a segmentation fault.
`QWebEnginePage::KilledTerminationStatus` | `3` | The render process was killed, for example by `SIGKILL` or task manager kill.

This enum was introduced or modified in Qt 5.6.

### enum QWebEnginePage::WebAction

This enum describes the types of action which can be performed on the web page.

Actions only have an effect when they are applicable. The availability of actions can be be determined by checking isEnabled() on the action returned by action().

Constant | Value | Description
--- | --- | ---
`QWebEnginePage::NoWebAction` | `- 1` | No action is triggered.
`QWebEnginePage::Back` | `0` | Navigate back in the history of navigated links.
`QWebEnginePage::Forward` | `1` | Navigate forward in the history of navigated links.
`QWebEnginePage::Stop` | `2` | Stop loading the current page.
`QWebEnginePage::Reload` | `3` | Reload the current page.
`QWebEnginePage::ReloadAndBypassCache` | `10` | Reload the current page, but do not use any local cache.
`QWebEnginePage::Cut` | `4` | Cut the content currently selected into the clipboard.
`QWebEnginePage::Copy` | `5` | Copy the content currently selected into the clipboard.
`QWebEnginePage::Paste` | `6` | Paste content from the clipboard.
`QWebEnginePage::Undo` | `7` | Undo the last editing action.
`QWebEnginePage::Redo` | `8` | Redo the last editing action.
`QWebEnginePage::SelectAll` | `9` | Select all content.
`QWebEnginePage::PasteAndMatchStyle` | `11` | Paste content from the clipboard with current style.
`QWebEnginePage::OpenLinkInThisWindow` | `12` | Open the current link in the current window. (Added in Qt 5.6)
`QWebEnginePage::OpenLinkInNewWindow` | `13` | Open the current link in a new window. (Added in Qt 5.6)
`QWebEnginePage::OpenLinkInNewTab` | `14` | Open the current link in a new tab. (Added in Qt 5.6)
`QWebEnginePage::OpenLinkInNewBackgroundTab` | `31` | Open the current link in a new background tab. (Added in Qt 5.7)
`QWebEnginePage::CopyLinkToClipboard` | `15` | Copy the current link to the clipboard. (Added in Qt 5.6)
`QWebEnginePage::CopyImageToClipboard` | `17` | Copy the clicked image to the clipboard. (Added in Qt 5.6)
`QWebEnginePage::CopyImageUrlToClipboard` | `18` | Copy the clicked image's URL to the clipboard. (Added in Qt 5.6)
`QWebEnginePage::CopyMediaUrlToClipboard` | `20` | Copy the hovered audio or video's URL to the clipboard. (Added in Qt 5.6)
`QWebEnginePage::ToggleMediaControls` | `21` | Toggle between showing and hiding the controls for the hovered audio or video element. (Added in Qt 5.6)
`QWebEnginePage::ToggleMediaLoop` | `22` | Toggle whether the hovered audio or video should loop on completetion or not. (Added in Qt 5.6)
`QWebEnginePage::ToggleMediaPlayPause` | `23` | Toggle the play/pause state of the hovered audio or video element. (Added in Qt 5.6)
`QWebEnginePage::ToggleMediaMute` | `24` | Mute or unmute the hovered audio or video element. (Added in Qt 5.6)
`QWebEnginePage::DownloadLinkToDisk` | `16` | Download the current link to the disk. (Added in Qt 5.6)
`QWebEnginePage::DownloadImageToDisk` | `19` | Download the highlighted image to the disk. (Added in Qt 5.6)
`QWebEnginePage::DownloadMediaToDisk` | `25` | Download the hovered audio or video to the disk. (Added in Qt 5.6)
`QWebEnginePage::InspectElement` | `26` | Trigger any attached Web Inspector to inspect the highlighed element. (Added in Qt 5.6)
`QWebEnginePage::ExitFullScreen` | `27` | Exit the fullscreen mode. (Added in Qt 5.6)
`QWebEnginePage::RequestClose` | `28` | Request to close the web page. If defined, the `window.onbeforeunload` handler is run, and the user can confirm or reject to close the page. If the close request is confirmed, `windowCloseRequested` is emitted. (Added in Qt 5.6)
`QWebEnginePage::Unselect` | `29` | Clear the current selection. (Added in Qt 5.7)
`QWebEnginePage::SavePage` | `30` | Save the current page to disk. MHTML is the default format that is used to store the web page on disk. (Added in Qt 5.7)
`QWebEnginePage::ViewSource` | `32` | Show the source of the current page in a new tab. (Added in Qt 5.8)
`QWebEnginePage::ToggleBold` | `33` | Toggles boldness for the selection or at the cursor position. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::ToggleItalic` | `34` | Toggles italics for the selection or at the cursor position. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::ToggleUnderline` | `35` | Toggles underlining of the selection or at the cursor position. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::ToggleStrikethrough` | `36` | Toggles striking through the selection or at the cursor position. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::AlignLeft` | `37` | Aligns the lines containing the selection or the cursor to the left. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::AlignCenter` | `38` | Aligns the lines containing the selection or the cursor at the center. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::AlignRight` | `39` | Aligns the lines containing the selection or the cursor to the right. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::AlignJustified` | `40` | Stretches the lines containing the selection or the cursor so that each line has equal width. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::Indent` | `41` | Indents the lines containing the selection or the cursor. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::Outdent` | `42` | Outdents the lines containing the selection or the cursor. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::InsertOrderedList` | `43` | Inserts an ordered list at the current cursor position, deleting the current selection. Requires `contenteditable="true"`. (Added in Qt 5.10)
`QWebEnginePage::InsertUnorderedList` | `44` | Inserts an unordered list at the current cursor position, deleting the current selection. Requires `contenteditable="true"`. (Added in Qt 5.10)

### enum QWebEnginePage::WebWindowType

This enum describes the types of window that can be created by the createWindow() function:

Constant | Value | Description
--- | --- | ---
`QWebEnginePage::WebBrowserWindow` | `0` | A complete web browser window.
`QWebEnginePage::WebBrowserTab` | `1` | A web browser tab.
`QWebEnginePage::WebDialog` | `2` | A window without decoration.
`QWebEnginePage::WebBrowserBackgroundTab` | `3` | A web browser tab without hiding the current visible WebEngineView. (Added in Qt 5.7)

## Property Documentation

### audioMuted : bool

This property holds whether the current page audio is muted.

The default value is `false`.

This property was introduced in Qt 5.7.

Access functions:

bool | isAudioMuted() const
void | setAudioMuted(bool muted)

Notifier signal:

void | audioMutedChanged(bool muted)

See also recentlyAudible.

### backgroundColor : QColor

This property holds the page's background color behind the document's body.

You can set the background color to Qt::transparent or to a translucent color to see through the document, or you can set it to match your web content in a hybrid application to prevent the white flashes that may appear during loading.

The default value is white.

This property was introduced in Qt 5.6.

Access functions:

QColor | backgroundColor() const
void | setBackgroundColor(const QColor &color)

### contentsSize : const QSizeF

The size of the page contents.

This property was introduced in Qt 5.7.

Access functions:

QSizeF | contentsSize() const

Notifier signal:

void | contentsSizeChanged(const QSizeF &size)

### hasSelection : const bool

This property holds whether this page contains selected content or not.

Access functions:

bool | hasSelection() const

See also selectionChanged().

### icon : const QIcon

This property holds the icon associated with the page currently viewed

By default, this property contains a null icon. If the web page specifies more than one icon, the `icon` property encapsulates the available candidate icons in a single, scalable `QIcon`.

This property was introduced in Qt 5.7.

Access functions:

QIcon | icon() const

Notifier signal:

void | iconChanged(const QIcon &icon)

See also iconChanged(), iconUrl(), and iconUrlChanged().

### iconUrl : const QUrl

This property holds the URL of the icon associated with the page currently viewed

By default, this property contains an empty URL.

Access functions:

QUrl | iconUrl() const

Notifier signal:

void | iconUrlChanged(const QUrl &url)

See also iconUrlChanged(), icon(), and iconChanged().

### recentlyAudible : const bool

This property holds the current page's audible state, that is, whether audio was recently played or not.

The default value is `false`.

This property was introduced in Qt 5.7.

Access functions:

bool | recentlyAudible() const

Notifier signal:

void | recentlyAudibleChanged(bool recentlyAudible)

See also audioMuted.

### requestedUrl : const QUrl

This property holds the URL that was originally requested to be loaded by the page that is currently viewed

Note: The URL may differ from the one returned by url(), which is the actual URL that results from DNS resolution or redirection.

Access functions:

QUrl | requestedUrl() const

See also url() and setUrl().

### scrollPosition : const QPointF

This property holds the scroll position of the page contents.

This property was introduced in Qt 5.7.

Access functions:

QPointF | scrollPosition() const

Notifier signal:

void | scrollPositionChanged(const QPointF &position)

### selectedText : const QString

This property holds the text currently selected

By default, this property contains an empty string.

Access functions:

QString | selectedText() const

See also selectionChanged().

### title : const QString

This property holds the title of the page as defined by the HTML `<title>` element

Access functions:

QString | title() const

See also titleChanged().

### url : QUrl

This property holds the URL of the page currently viewed

Setting this property clears the view and loads the URL.

By default, this property contains an empty, invalid URL.

Access functions:

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

See also urlChanged().

### zoomFactor : qreal

This property holds the zoom factor for the page content

Valid values are within the range from `0.25` to `5.0`. The default factor is `1.0`.

Access functions:

qreal | zoomFactor() const
void | setZoomFactor(qreal factor)

## Member Function Documentation

### QWebEnginePage::QWebEnginePage(QObject *parent = Q_NULLPTR)

Default constructs an instance of QWebEnginePage.

### QWebEnginePage::QWebEnginePage(QWebEngineProfile *profile, QObject *parent = Q_NULLPTR)

Constructs an empty web engine page in the web engine profile profile with the parent parent.

If the profile is not the default profile, the caller must ensure that the profile stays alive for as long as the page does.

This function was introduced in Qt 5.5.

### `[virtual]` QWebEnginePage::~QWebEnginePage()

Destroys the instance of QWebEnginePage. The destructor is virtual.

### `[virtual protected]` bool QWebEnginePage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)

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

### `[signal]` void QWebEnginePage::authenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator)

### `[virtual protected]` bool QWebEnginePage::certificateError(const QWebEngineCertificateError &certificateError)

### `[virtual protected]` QStringList QWebEnginePage::chooseFiles(QWebEnginePage::FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes)

### const QWebEngineContextMenuData &QWebEnginePage::contextMenuData() const

Returns additional data about the current context menu. It is only guaranteed to be valid during the call to the QWebEngineView::contextMenuEvent() handler of the associated QWebEngineView.

This function was introduced in Qt 5.7.

See also createStandardContextMenu().

### QMenu *QWebEnginePage::createStandardContextMenu()

### `[virtual protected]` QWebEnginePage *QWebEnginePage::createWindow(QWebEnginePage::WebWindowType type)

### QWebEnginePage *QWebEnginePage::devToolsPage() const

Returns the page that is hosting the developer tools of this page, if any.

Returns `nullptr` if no developer tools page is set.

This function was introduced in Qt 5.11.

See also setDevToolsPage() and inspectedPage().

### void QWebEnginePage::download(const QUrl &url, const QString &filename = QString())

Downloads the resource from the location given by url to a local file.

If filename is given, it is used as the suggested file name. If it is relative, the file is saved in the standard download location with the given name. If it is a null or empty QString, the default file name is used.

This will emit QWebEngineProfile::downloadRequested() after the download has started.

This function was introduced in Qt 5.10.

### `[virtual]` bool QWebEnginePage::event(QEvent *e)

### `[signal]` void QWebEnginePage::featurePermissionRequestCanceled(const QUrl &securityOrigin, QWebEnginePage::Feature feature)

### `[signal]` void QWebEnginePage::featurePermissionRequested(const QUrl &securityOrigin, QWebEnginePage::Feature feature)

### void QWebEnginePage::findText(const QString &subString, QWebEnginePage::FindFlags options = FindFlags(), const QWebEngineCallback<bool> &resultCallback = QWebEngineCallback<bool>())

### `[signal]` void QWebEnginePage::fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest)

### `[signal]` void QWebEnginePage::geometryChangeRequested(const QRect &geom)

### QWebEngineHistory *QWebEnginePage::history() const

### QWebEnginePage *QWebEnginePage::inspectedPage() const

Returns the page this page is inspecting, if any.

Returns `nullptr` if this page is not a developer tools page.

This function was introduced in Qt 5.11.

See also setInspectedPage() and devToolsPage().

### `[virtual protected]` void QWebEnginePage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg)

### `[virtual protected]` bool QWebEnginePage::javaScriptConfirm(const QUrl &securityOrigin, const QString &msg)

### `[virtual protected]` void QWebEnginePage::javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID)

### `[virtual protected]` bool QWebEnginePage::javaScriptPrompt(const QUrl &securityOrigin, const QString &msg, const QString &defaultValue, QString *result)

### `[signal]` void QWebEnginePage::linkHovered(const QString &url)

### void QWebEnginePage::load(const QUrl &url)

### void QWebEnginePage::load(const QWebEngineHttpRequest &request)

Issues the specified request and loads the response.

This function was introduced in Qt 5.9.

See also load(), setUrl(), url(), urlChanged(), and QUrl::fromUserInput().

### `[signal]` void QWebEnginePage::loadFinished(bool ok)

### `[signal]` void QWebEnginePage::loadProgress(int progress)

### `[signal]` void QWebEnginePage::loadStarted()

### `[signal]` void QWebEnginePage::pdfPrintingFinished(const QString &filePath, bool success)

### void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback)

Renders the current content of the page into a temporary PDF document, then prints it using printer.

The settings for creating and printing the PDF document will be retrieved from the printer object. It is the users responsibility to ensure the printer remains valid until resultCallback has been called.

Note: The rendering of the current content into a temporary PDF document is asynchronous and does not block the main thread. However, the subsequent rendering of PDF into printer runs on the main thread and will therefore block the event loop. Moreover, printing runs on the browser process, which is by default not sandboxed.

The resultCallback must take a boolean as parameter. If printing was successful, this boolean will have the value `true`, otherwise, its value will be `false`.

This function was introduced in Qt 5.8.

### void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &pageLayout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()))

Renders the current content of the page into a PDF document and saves it in the location specified in filePath. The page size and orientation of the produced PDF document are taken from the values specified in pageLayout.

This method issues an asynchronous request for printing the web page into a PDF and returns immediately. To be informed about the result of the request, connect to the signal pdfPrintingFinished().

If a file already exists at the provided file path, it will be overwritten.

This function was introduced in Qt 5.7.

See also pdfPrintingFinished().

### void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray &> &resultCallback, const QPageLayout &pageLayout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()))

Renders the current content of the page into a PDF document and returns a byte array containing the PDF data as parameter to resultCallback. The page size and orientation of the produced PDF document are taken from the values specified in pageLayout.

The resultCallback must take a const reference to a QByteArray as parameter. If printing was successful, this byte array will contain the PDF data, otherwise, the byte array will be empty.

This function was introduced in Qt 5.7.

### QWebEngineProfile *QWebEnginePage::profile() const

Returns the web engine profile the page belongs to.

This function was introduced in Qt 5.5.

### `[signal]` void QWebEnginePage::proxyAuthenticationRequired(const QUrl &requestUrl, QAuthenticator *authenticator, const QString &proxyHost)

### `[signal]` void QWebEnginePage::quotaRequested(QWebEngineQuotaRequest quotaRequest)

### `[signal]` void QWebEnginePage::registerProtocolHandlerRequested(QWebEngineRegisterProtocolHandlerRequest request)

### `[signal]` void QWebEnginePage::renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode)

### void QWebEnginePage::replaceMisspelledWord(const QString &replacement)

Replace the current misspelled word with replacement.

The current misspelled word can be found in QWebEngineContextMenuData::misspelledWord(), and suggested replacements in QWebEngineContextMenuData::spellCheckerSuggestions().

This function was introduced in Qt 5.8.

See also contextMenuData().

### void QWebEnginePage::runJavaScript(const QString &scriptSource)

### void QWebEnginePage::runJavaScript(const QString &scriptSource, quint32 worldId)

### void QWebEnginePage::runJavaScript(const QString &scriptSource, const QWebEngineCallback<const QVariant &> &resultCallback)

### void QWebEnginePage::runJavaScript(const QString &scriptSource, quint32 worldId, const QWebEngineCallback<const QVariant &> &resultCallback)

### void QWebEnginePage::save(const QString &filePath, QWebEngineDownloadItem::SavePageFormat format = QWebEngineDownloadItem::MimeHtmlSaveFormat) const

Save the currently loaded web page to disk.

The web page is saved to filePath in the specified format.

This is a short cut for the following actions:

- Trigger the Save web action.
- Accept the next download item and set the specified file path and save format.

This function issues an asynchronous download request for the web page and returns immediately.

This function was introduced in Qt 5.8.

See also QWebEngineDownloadItem::SavePageFormat.

### QWebEngineScriptCollection &QWebEnginePage::scripts()

Returns the collection of scripts that are injected into the page.

In addition, a page might also execute scripts added through QWebEngineProfile::scripts().

See also QWebEngineScriptCollection and QWebEngineScript.

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

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

### void QWebEnginePage::setDevToolsPage(QWebEnginePage *devToolsPage)

Binds devToolsPage to be the developer tools of this page. Triggers devToolsPage to navigate to an internal URL with the developer tools.

This is the same as calling setInspectedPage() on devToolsPage with `this` as argument.

This function was introduced in Qt 5.11.

See also devToolsPage() and setInspectedPage().

### void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEnginePage::Feature feature, QWebEnginePage::PermissionPolicy policy)

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

### void QWebEnginePage::setInspectedPage(QWebEnginePage *page)

Navigates this page to an internal URL that is the developer tools of page.

This is the same as calling setDevToolsPage() on page with `this` as argument.

This function was introduced in Qt 5.11.

See also inspectedPage() and setDevToolsPage().

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

See also view().

### void QWebEnginePage::setWebChannel(QWebChannel *channel, uint worldId)

Sets the web channel instance to be used by this page to channel and connects it to web engine's transport using Chromium IPC messages. The transport is exposed in the JavaScript world worldId as `qt.webChannelTransport`, which should be used when using the Qt WebChannel JavaScript API.

Note: The page does not take ownership of the channel object.

Note: Only one web channel can be installed per page, setting one even in another JavaScript world uninstalls any already installed web channel.

This function was introduced in Qt 5.7.

See also webChannel() and QWebEngineScript::ScriptWorldId.

### void QWebEnginePage::setWebChannel(QWebChannel *channel)

This is an overloaded function.

Sets the web channel instance to be used by this page to channel and installs it in the main JavaScript world.

With this method the web channel can be accessed by web page content. If the content is not under your control and might be hostile, this could be a security issue and you should consider installing it in a private JavaScript world.

This function was introduced in Qt 5.5.

See also QWebEngineScript::MainWorld.

### QWebEngineSettings *QWebEnginePage::settings() const

### `[signal]` void QWebEnginePage::titleChanged(const QString &title)

### void QWebEnginePage::toHtml(const QWebEngineCallback<const QString &> &resultCallback) const

### void QWebEnginePage::toPlainText(const QWebEngineCallback<const QString &> &resultCallback) const

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

### `[signal]` void QWebEnginePage::urlChanged(const QUrl &url)

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

See also setView().

### QWebChannel *QWebEnginePage::webChannel() const

Returns a pointer to the web channel instance used by this page or a null pointer if none was set. This channel automatically uses the internal web engine transport mechanism over Chromium IPC that is exposed in the JavaScript context of this page as `qt.webChannelTransport`.

This function was introduced in Qt 5.5.

See also setWebChannel().

### `[signal]` void QWebEnginePage::windowCloseRequested()