WebEngineView QML Type

A WebEngineView renders web content within a QML application. More...

Import Statement: import QtWebEngine 1.0
Since: QtWebEngine 1.0

Properties

Signals

Methods

Detailed Description

Property Documentation

ErrorDomain : enumeration

This enumeration details various high-level error types.

ConstantDescription
NoErrorDomain 
WebEngineView::InternalErrorDomainContent fails to be interpreted by Qt WebEngine.
WebEngineView::ConnectionErrorDomainError results from faulty network connection.
WebEngineView::CertificateErrorDomainError related to the SSL/TLS certficate.
WebEngineView::HttpErrorDomainError related to the HTTP connection.
WebEngineView::FtpErrorDomainError related to the FTP connection.
WebEngineView::DnsErrorDomainError related to the DNS connection.

JavaScriptConsoleMessageLevel : enumeration

Indicates the severity of a JavaScript console message.

ConstantDescription
InfoMessageLevelMessage is purely informative and should be safe to ignore.
WarningMessageLevelMessage indicates there might be a problem that may need attention.
ErrorMessageLevelMessage indicates there has been an error.

LoadStatus : enumeration

Reflects a page's load status.

ConstantDescription
LoadStartedStatusPage is currently loading.
LoadSucceededStatusPage has successfully loaded, and is not currently loading.
LoadFailedStatusPage has failed to load, and is not currently loading.

canGoBack : bool

Returns true if there are prior session history entries, false otherwise.


canGoForward : bool

Returns true if there are subsequent session history entries, false otherwise.


read-onlyicon : url

This property holds the location of the currently displaying web site icon, also known as favicon or shortcut icon. This read-only URL corresponds to the image used within a mobile browser application to represent a bookmarked page on the device's home screen.

The following snippet uses the icon property to build an Image component:

Image {
    id: appIcon
    source: webView.icon != "" ? webView.icon : "fallbackFavIcon.png";
    ...
}

loadProgress : int

This property holds the amount of the page that has been loaded, expressed as an integer percentage in the range from 0 to 100.


loading : bool

Returns true if the HTML page is currently loading, false otherwise.


read-onlytitle : string

This property holds the title of the currently displaying HTML page, a read-only value that reflects the contents of the <title> tag.


url : url

The location of the currently displaying HTML page. This writable property offers the main interface to load a page into a web view. It functions the same as the window.location DOM property.

See also WebEngineView::loadHtml().


Signal Documentation

linkHovered(hoveredUrl, hoveredTitle)

Within a mouse-driven interface, this signal is emitted when a mouse pointer passes over a link, corresponding to the mouseover DOM event. This event may also occur in touch interfaces for mouseover events that are not cancelled with preventDefault(). hoveredUrl provides the link's location, and hoveredTitle is any available link text.

The corresponding handler is onLinkHovered.


loadingChanged(loadRequest)

This signal is emitted when a page load begins, ends, or fails. The corresponding handler is onLoadingChanged.

When handling the signal with onLoadingChanged, various read-only parameters are available on the loadRequest:

PropertyDescription
urlThe location of the resource that is loading.
statusReflects one of four load states: WebEngineView::LoadStartedStatus, WebEngineView::LoadStoppedStatus, WebEngineView::LoadSucceededStatus, or WebEngineView::LoadFailedStatus. See WebEngineLoadRequest::status and WebEngineView::LoadStatus.
errorStringThe description of load error.
errorCodeThe HTTP error code.
errorDomainThe high-level error types, one of WebEngineView::ConnectionErrorDomain, WebEngineView::HttpErrorDomain, WebEngineView::InternalErrorDomain, WebEngineView::DownloadErrorDomain, or WebEngineView::NoErrorDomain. See WebEngineView::ErrorDomain for the full list.

See also WebEngineView::loading.


Method Documentation

void goBack()

Go backward within the browser's session history, if possible. This function is equivalent to the window.history.back() DOM method.

See also WebEngineView::canGoBack.


void goForward()

Go forward within the browser's session history, if possible. This function is equivalent to the window.history.forward() DOM method.


void loadHtml(string html, url baseUrl)

Loads the specified html as the content of the web view.

This method offers a lower-level alternative to the url property, which references HTML pages via URL.

External objects such as stylesheets or images referenced in the HTML document should be located relative to baseUrl. For example, if html is retrieved from http://www.example.com/documents/overview.html, which is the base url, then an image referenced with the relative url, diagram.png, should be at http://www.example.com/documents/diagram.png.

See also WebEngineView::url.


void reload()

Reloads the current page. This function is equivalent to the window.location.reload() DOM method.


void runJavaScript(string script, variant callback)

Runs the specified script in the content of the web view.

In case a callback function is provided it will be invoked after the script finished running.

runJavaScript("document.title", function(result) { console.log(result); });

void stop()

Stops loading the current page.


© 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.