WebEngineView QML Type

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

Import Statement: import QtWebEngine 1.3
Since: QtWebEngine 1.0

Properties

Signals

Methods

Detailed Description

The WebEngineView type enables QML applications to render regions of dynamic web content. It may share the screen with other QML types, such as a TabView, or fill the screen, as specified within the QML application.

Initializing Web Engine

For the web engine view to be rendered, the web engine must be initialized by using QtWebEngine::initialize in the application main source file, as illustrated by the following code snippet:

int main(int argc, char *argv[])
{
    QGuiApplication app(argc, argv);
    QtWebEngine::initialize();

    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

    return app.exec();
}

Loading Web Pages

An application can load pages into the WebEngineView, using either the url property or the loadHtml method and navigate within the view's session history. The GET method is always used to load URLs.

The history is represented by a WebEngineHistory data model that is held by the navigationHistory property.

The following sample QML application loads a web page using the url property:

import QtQuick 2.0
import QtQuick.Window 2.0
import QtWebEngine 1.0

Window {
    width: 1024
    height: 750
    visible: true
    WebEngineView {
        anchors.fill: parent
        url: "http://www.qt.io"
    }
}

The loading property holds whether an HTML page is currently loading. The loadingChanged() signal is emitted when loading the page begins, ends, or fails.

The title of an HTML page can be accessed with the title property. Additionally, a web page may specify an icon, which can be accessed using the icon property. The zoomFactor property enables zooming the contents of the web page by a scale factor.

If a certificate error is raised while loading a web page, the certificateError() signal is emitted. Certificate errors are handled by using the methods of the WebEngineCertificateError type.

Interaction

By default, links to different pages load within the same WebEngineView object, but web sites may request them to be opened as a new tab, window, or dialog. The newViewRequested() signal is emitted when a request to load the page in a separate web engine view is issued. The NewViewDestination property describes how the new view should be opened. In addition, the WebEngineNewViewRequest utility type can be used to load web pages in separate web engine views.

The findText() method can be used to search for a string on a web page, using the options described by FindFlags.

The setActiveFocusOnPress() method can be used to create a UI element that should not get focus. This can be useful in a hybrid UI.

The linkHovered() signal is emitted when a mouse pointer passes over a link and thus corresponds to the mouseover DOM event.

Actions, such as selecting and editing content, can be performed on a web page by using the triggerWebAction() method. The available actions are described by the WebAction property.

The backgroundColorChanged() signal is emitted when the web page background color changes.

User Scripts

During the loading of a page, so called user scripts can be injected in the JavaScript engine at different points. The script objects attached to the web engine view are held by the userScripts property and injected by using the WebEngineScript type. Scripts can also be run by using the runJavaScript() method in the same world as other scripts that are part of the loaded site.

The webChannel property can be used to expose a WebChannel instance in the JavaScript context of the page it is rendering as qt.webChannelTransport.

Fullscreen Mode

A web page can request through the JavaScript API to be loaded in fullscreen mode. The fullScreenRequested() signal is emitted when the web page issues the request. The WebEngineFullScreenRequest utility type can be used to toggle fullscreen requests. The fullScreenCancelled method can be used to notify the browser engine when the windowing system forces the application to leave fullscreen mode.

Profiles

Web engine views can be isolated from each other by using the WebEngineProfile type. A profile contains settings, scripts, and the list of visited links shared by all views that belong to the profile. For example, a dedicated profile could be created for a private browsing mode. The current profile for the view is held by the profile property and the current settings are held by the settings property. The settings are specified by using the WebEngineSettings type.

Platform Features

Web pages can request access to platform features, such as geolocation or audio and video capture devices. The featurePermissionRequested() signal is emitted when a web page requests to make use of a resource. The supported platform features are described by the Feature property. If users grant the permission, the grantFeaturePermission() method is used to set it to granted.

Rendering to OpenGL Surface

When using a QQuickRenderControl to render a Qt Quick user interface to an OpenGL surface, the WebEngineView type is not rendered correctly. The web engine view attempts to use a global OpenGL context created by QtWebEngine::initialize, but there is no public API for accessing that context in order to share it with the QQuickRenderControl context.

To have the web engine view rendered correctly, it is possible to manually create a new offscreen context that is shared with the QQuickRenderControl and to call the non-public function qt_gl_set_global_share_context(), rather than calling initialize(). If initialize() is called after setting a global context, it will do nothing.

Property Documentation

ErrorDomain : enumeration

Describes various high-level error types:

ConstantDescription
WebEngineView::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.

Feature : enumeration

Describes the platform feature access categories that the user may be asked to grant or deny access to:

ConstantDescription
GeolocationLocation hardware or service.
MediaAudioCaptureAudio capture devices, such as microphones.
MediaVideoCaptureVideo devices, such as cameras.
MediaAudioVideoCaptureBoth audio and video capture devices.

See also featurePermissionRequested() and grantFeaturePermission().


FindFlags : enumeration

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

ConstantDescription
FindBackwardSearches backwards instead of forwards.
FindCaseSensitivelyBy default findText() works case insensitive. Specifying this option changes the behavior to a case sensitive find operation.

See also findText().


JavaScriptConsoleMessageLevel : enumeration

Indicates the severity of a JavaScript console message:

ConstantDescription
InfoMessageLevelMessage is purely informative and can safely be ignored.
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.

NewViewDestination : enumeration

Describes how to open a new view:

ConstantDescription
WebEngineView::NewViewInWindowIn a separate Window.
WebEngineView::NewViewInTabIn a tab of the same window.
WebEngineView::NewViewInDialogIn a Window without a tab bar, toolbar, or URL bar.
WebEngineView::NewViewInBackgroundTabIn a tab of the same window, without hiding the currently visible web engine view.

See also WebEngineNewViewRequest::destination.


PrintedPageOrientation : enumeration

Describes the orientation of a PDF document that gets created from the WebEngineView's contents. The enumeration values are mapped from and must match QPageLayout::Orientation.

ConstantDescription
PortraitThe document will be created using portrait orientation.
LandscapeThe document will be created using landscape orientation.

This QML property was introduced in QtWebEngine 1.3.

See also WebEngineView::printToPdf().


PrintedPageSizeId : enumeration

This enum type lists the available page sizes as defined in the Postscript PPD standard.

The enumeration values are mapped from and must match QPageSize::PageSizeId. They are also duplicated in QPagedPaintDevice and QPrinter.

The defined sizes are:

ConstantDescription
A0841 x 1189 mm
A1594 x 841 mm
A2420 x 594 mm
A3297 x 420 mm
A4210 x 297 mm, 8.26 x 11.69 inches
A5148 x 210 mm
A6105 x 148 mm
A774 x 105 mm
A852 x 74 mm
A937 x 52 mm
B01000 x 1414 mm
B1707 x 1000 mm
B2500 x 707 mm
B3353 x 500 mm
B4250 x 353 mm
B5176 x 250 mm, 6.93 x 9.84 inches
B6125 x 176 mm
B788 x 125 mm
B862 x 88 mm
B944 x 62 mm
B1031 x 44 mm
C5E163 x 229 mm
Comm10E105 x 241 mm, U.S. Common 10 Envelope
DLE110 x 220 mm
Executive7.5 x 10 inches, 190.5 x 254 mm
Folio210 x 330 mm
Ledger431.8 x 279.4 mm
Legal8.5 x 14 inches, 215.9 x 355.6 mm
Letter8.5 x 11 inches, 215.9 x 279.4 mm
Tabloid279.4 x 431.8 mm
CustomUnknown, or a user defined size.
A10 
A3Extra 
A4Extra 
A4Plus 
A4Small 
A5Extra 
B5Extra 
JisB0 
JisB1 
JisB2 
JisB3 
JisB4 
JisB5 
JisB6 
JisB7 
JisB8 
JisB9 
JisB10 
AnsiA= Letter
AnsiB= Ledger
AnsiC 
AnsiD 
AnsiE 
LegalExtra 
LetterExtra 
LetterPlus 
LetterSmall 
TabloidExtra 
ArchA 
ArchB 
ArchC 
ArchD 
ArchE 
Imperial7x9 
Imperial8x10 
Imperial9x11 
Imperial9x12 
Imperial10x11 
Imperial10x13 
Imperial10x14 
Imperial12x11 
Imperial15x11 
ExecutiveStandard 
Note 
Quarto 
Statement 
SuperA 
SuperB 
Postcard 
DoublePostcard 
Prc16K 
Prc32K 
Prc32KBig 
FanFoldUS 
FanFoldGerman 
FanFoldGermanLegal 
EnvelopeB4 
EnvelopeB5 
EnvelopeB6 
EnvelopeC0 
EnvelopeC1 
EnvelopeC2 
EnvelopeC3 
EnvelopeC4 
EnvelopeC5= C5E
EnvelopeC6 
EnvelopeC65 
EnvelopeC7 
EnvelopeDL= DLE
Envelope9 
Envelope10= Comm10E
Envelope11 
Envelope12 
Envelope14 
EnvelopeMonarch 
EnvelopePersonal 
EnvelopeChou3 
EnvelopeChou4 
EnvelopeInvite 
EnvelopeItalian 
EnvelopeKaku2 
EnvelopeKaku3 
EnvelopePrc1 
EnvelopePrc2 
EnvelopePrc3 
EnvelopePrc4 
EnvelopePrc5 
EnvelopePrc6 
EnvelopePrc7 
EnvelopePrc8 
EnvelopePrc9 
EnvelopePrc10 
EnvelopeYou4 
LastPageSize= EnvelopeYou4

This QML property was introduced in QtWebEngine 1.3.

See also WebEngineView::printToPdf().


RenderProcessTerminationStatus : enumeration

Describes the status with which the render process terminated:

ConstantDescription
NormalTerminationStatusThe render process terminated normally.
AbnormalTerminationStatusThe render process terminated with a non-zero exit status.
CrashedTerminationStatusThe render process crashed, for example because of a segmentation fault.
KilledTerminationStatusThe render process was killed, for example by SIGKILL or task manager kill.

This QML property was introduced in QtWebEngine 1.2.


WebAction : enumeration

Describes the types of action that can be performed on a web page:

ConstantDescription
NoWebActionNo action is triggered.
BackNavigate back in the history of navigated links.
ForwardNavigate forward in the history of navigated links.
StopStop loading the current page.
ReloadReload the current page.
ReloadAndBypassCacheReload the current page, but do not use any local cache.
CutCut the content currently selected into the clipboard.
CopyCopy the content currently selected into the clipboard.
PastePaste content from the clipboard.
UndoUndo the last editing action.
RedoRedo the last editing action.
SelectAllSelect all content.
PasteAndMatchStylePaste content from the clipboard with current style.
OpenLinkInThisWindowOpen the current link in the current window. (Added in Qt 5.6)
OpenLinkInNewWindowOpen the current link in a new window. (Added in Qt 5.6)
OpenLinkInNewTabOpen the current link in a new tab. (Added in Qt 5.6)
CopyLinkToClipboardCopy the current link to the clipboard. (Added in Qt 5.6)
CopyImageToClipboardCopy the clicked image to the clipboard. (Added in Qt 5.6)
CopyImageUrlToClipboardCopy the clicked image's URL to the clipboard. (Added in Qt 5.6)
CopyMediaUrlToClipboardCopy the hovered audio or video's URL to the clipboard. (Added in Qt 5.6)
ToggleMediaControlsToggle between showing and hiding the controls for the hovered audio or video element. (Added in Qt 5.6)
ToggleMediaLoopToggle whether the hovered audio or video should loop on completetion or not. (Added in Qt 5.6)
ToggleMediaPlayPauseToggle the play/pause state of the hovered audio or video element. (Added in Qt 5.6)
ToggleMediaMuteMute or unmute the hovered audio or video element. (Added in Qt 5.6)
DownloadLinkToDiskDownload the current link to the disk. (Added in Qt 5.6)
DownloadImageToDiskDownload the highlighted image to the disk. (Added in Qt 5.6)
DownloadMediaToDiskDownload the hovered audio or video to the disk. (Added in Qt 5.6)
InspectElementTrigger any attached Web Inspector to inspect the highlighed element. (Added in Qt 5.6)
ExitFullScreenExit the fullscreen mode. (Added in Qt 5.6)
SavePageSave the current web page to disk. (Added in Qt 5.7)

This QML property was introduced in QtWebEngine 1.2.


audioMuted : bool

The state of whether the current page audio is muted.

This QML property was introduced in QtWebEngine 1.3.

See also recentlyAudible.


[read-only] canGoBack : bool

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


[read-only] canGoForward : bool

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


contentsSize : QSizeF

Size of the page contents.

This QML property was introduced in QtWebEngine 1.3.


[read-only] icon : url

An internal URL for accessing the currently displayed web site icon, also known as favicon or shortcut icon. The icon is already downloaded and stored by the Qt WebEngine's favicon manager. 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
    sourceSize: Qt.size(32, 32)
    source: webView.icon != "" ? webView.icon : "fallbackFavicon.png";
    // ...
}

Specifying the sourceSize property of the Image element informs the Qt WebEngine's favicon provider about the requested size. The favicon provider tries to find the best fit among the web page candidate icons. If sourceSize property is not specified, the provider provides the icon with the largest resolution.


[read-only] isFullScreen : bool

Returns true if the web view is in fullscreen mode, false otherwise.

This QML property was introduced in QtWebEngine 1.1.

See also fullScreenRequested() and fullScreenCancelled().


[read-only] loadProgress : int

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


[read-only] loading : bool

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


The navigation history of the current view.

This QML property was introduced in QtWebEngine 1.1.

See also WebEngineHistory.


profile : WebEngineProfile

The current profile used for the view.

This QML property was introduced in QtWebEngine 1.1.

See also WebEngineProfile.


[read-only] recentlyAudible : bool

Returns the current page's audible state (audio was recently played, or not).

This QML property was introduced in QtWebEngine 1.3.

See also audioMuted and recentlyAudibleChanged.


scrollPosition : QPointF

Scroll position of the page contents.

This QML property was introduced in QtWebEngine 1.3.


[read-only] settings : WebEngineSettings

Settings used by this view.

This QML property was introduced in QtWebEngine 1.1.

See also WebEngineSettings.


[read-only] title : string

The title of the currently displayed HTML page. This is a read-only value that reflects the contents of the <title> tag.


url : url

The location of the currently displayed 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 loadHtml().


[read-only] userScripts : list<WebEngineScript>

List of script objects attached to the view.

This QML property was introduced in QtWebEngine 1.1.

See also WebEngineScript.


webChannel : QQmlWebChannel

The web channel instance used by this view. This channel is automatically using the internal QtWebEngine transport mechanism over Chromium IPC, and exposed in the javascript context of the page it is rendering as qt.webChannelTransport. This transport object is used when instantiating the JavaScript counterpart of QWebChannel using the Qt WebChannel JavaScript API.

Note: The view does not take ownership for an assigned webChannel object.

This QML property was introduced in QtWebEngine 1.1.


webChannelWorld : uint

JavaScript world that the web channel instance used by this view is installed in.

This QML property was introduced in QtWebEngine 1.3.


zoomFactor : real

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

This QML property was introduced in QtWebEngine 1.1.


Signal Documentation

activeFocusOnPressChanged(bool)

This signal is emitted when the ability of the web engine view to get focus when clicked changes.

This QML signal was introduced in QtWebEngine 1.2.

See also setActiveFocusOnPress().


audioMutedChanged(bool muted)

This signal is emitted when the page's audio is (un)muted using audioMuted property.

Note: Not to be confused with a specific HTML5 audio / video element being muted.

This QML signal was introduced in QtWebEngine 1.3.

See also audioMuted and recentlyAudibleChanged.


backgroundColorChanged()

This signal is emitted when the web engine view background color changes.

This QML signal was introduced in QtWebEngine 1.2.


certificateError(error)

This signal is emitted when an invalid certificate error is raised while loading a given request.

The certificate error can be handled by using the methods of the WebEngineCertificateError type.

The corresponding handler is onCertificateError.

This QML signal was introduced in QtWebEngine 1.1.

See also WebEngineCertificateError.


featurePermissionRequested(url securityOrigin, Feature feature)

This signal is emitted when the web site identified by securityOrigin requests to make use of the resource or device identified by feature.

This QML signal was introduced in QtWebEngine 1.1.

See also grantFeaturePermission().


fullScreenRequested(WebEngineFullScreenRequest request)

This signal is emitted when the web page requests fullscreen mode through the JavaScript API.

The corresponding handler is onFullScreenRequested.

This QML signal was introduced in QtWebEngine 1.1.

See also WebEngineFullScreenRequest and isFullScreen.


javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, message, lineNumber, sourceID)

This signal is emitted when 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.

level indicates the severity of the event that triggered the message, that is, whether it was triggered by an error or a less severe event.

The corresponding handler is onJavaScriptConsoleMessage. If no handler is specified, the view will log the messages into a js logging category.

See also Console Logging.


linkHovered(hoveredUrl)

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.

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.
statusThe load status of the page.
errorStringThe description of load error.
errorCodeThe HTTP error code.
errorDomainThe high-level error type.

See also loading, LoadStatus, and ErrorDomain.


newViewRequested(request)

This signal is emitted when a page load is requested to happen in a separate web engine view. This can either be because the current page requested it explicitly through a JavaScript call to window.open, or because the user clicked on a link while holding Shift, Ctrl, or a built-in combination that triggers the page to open in a new window.

If this signal is not handled, the requested load will fail.

An example implementation:

QtObject {
    id: windowParent
    // Create the initial browsing windows and open the startup page.
    Component.onCompleted: {
        var firstWindow = windowComponent.createObject(windowParent)
        firstWindow.webView.loadHtml('<input type="button" value="Click!" onclick="window.open(&quot;http://qt.io&quot;)">')
    }

    property Component windowComponent: Window {
        // Destroy on close to release the Window's QML resources.
        // Because it was created with a parent, it won't be garbage-collected.
        onClosing: destroy()
        visible: true

        property WebEngineView webView: webView_
        WebEngineView {
            id: webView_
            anchors.fill: parent

            // Handle the signal. Dynamically create the window and
            // use its WebEngineView as the destination of our request.
            onNewViewRequested: {
                var newWindow = windowComponent.createObject(windowParent)
                request.openIn(newWindow.webView)
            }
        }
    }
}

The corresponding handler is onNewViewRequested.

This QML signal was introduced in QtWebEngine 1.1.

See also WebEngineNewViewRequest, NewViewDestination, and WebEngine Quick Nano Browser.


recentlyAudibleChanged(bool recentlyAudible)

This signal is emitted when the page's audible state is changed, due to audio being played or stopped.

Note: The signal is also emitted when the audioMuted property changes. Also if the audio is paused, this signal is emitted with an approximate two-second delay, from the moment the audio is paused.

This signal is also emitted for Flash plugin audio.

If a web page contains two videos that are started in sequence, this signal gets emitted only once, for the first video to generate sound. After both videos are stopped, the signal is emitted upon the last sound generated. This means that the signal is emitted both when any kind of sound is generated and when everything is completely silent within a web page, regardless of the number of audio streams.

Spurious signal emissions might also happen. For example, when sound is stopped, this signal gets emitted first with a value of true, and then with a value of false. Further, when audio starts playing, the signal is emitted twice with a value of true.

This QML signal was introduced in QtWebEngine 1.3.

See also recentlyAudible.


renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode)

This signal is emitted when the render process is terminated with a non-zero exit status. terminationStatus is the termination status of the process and exitCode is the status code with which the process terminated.

This QML signal was introduced in QtWebEngine 1.2.

See also RenderProcessTerminationStatus.


void wasRecentlyAudibleChanged(bool wasRecentlyAudible)

This signal is emitted when the page's audible state is changed, due to audio being played or stopped.

Note: The signal is also emitted when calling the setAudioMuted method. Also if the audio is paused, this signal is emitted with an approximate 2 second delay, from the moment the audio is paused.

This QML signal was introduced in QtWebEngine 1.3.


windowCloseRequested()

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

The corresponding handler is onWindowCloseRequested.

This QML signal was introduced in QtWebEngine 1.2.


Method Documentation

void findText(string subString, FindFlags options, variant resultCallback)

Finds the specified string, subString, in the page, using the given options.

To clear the selection, just pass an empty string.

The resultCallback must take a boolean parameter. It will be called with a value of true if the subString was found; otherwise the callback value will be false.

findText("Qt", WebEngineView.FindCaseSensitively, function(success) {
    if (success)
        console.log("Qt was found!");
});

This QML method was introduced in QtWebEngine 1.1.


void findText(string subString, FindFlags options)

Finds the specified string, subString, in the page, using the given options.

To clear the selection, just pass an empty string.

findText("Qt", WebEngineView.FindBackward | WebEngineView.FindCaseSensitively);

This QML method was introduced in QtWebEngine 1.1.


void findText(string subString)

Finds the specified string, subString, in the page.

To clear the selection, just pass an empty string.

This QML method was introduced in QtWebEngine 1.1.


void fullScreenCancelled()

Immediately sets isFullScreen property to false. It can be used to notify the browser engine when the windowing system forces the application to leave fullscreen mode.

ApplicationWindow {
    onVisibilityChanged: {
        if (webEngineView.isFullScreen && visibility != Window.FullScreen)
            webEngineView.fullScreenCancelled()
    }

    WebEngineView {
        id: webEngineView
        // ...
    }
}

This QML method was introduced in QtWebEngine 1.1.

See also isFullScreen and fullScreenRequested().


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


void goBackOrForward(int offset)

If offset is positive, goes forward the specified number of offset pages in the current session history. If offset is negative, it goes back. If the offset is invalid, the page is not changed.

This QML method was introduced in QtWebEngine 1.1.

See also goBack() and goForward().


void goForward()

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


void grantFeaturePermission(url securityOrigin, Feature feature, bool granted)

Sets or unsets the permission, depending on granted, for the web site identified by securityOrigin to use feature.

This QML method was introduced in QtWebEngine 1.1.

See also featurePermissionRequested().


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


void printToPdf(variant resultCallback, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation)

Prints the WebEngineView's current content to a PDF document and returns it in a byte array. The document's size will be determined by the value of pageSizeId and its orientation will be determined using orientation.

The resultCallback must take a string parameter. This string will contain the document's data upon successful printing and an empty string otherwise.

This QML method was introduced in QtWebEngine 1.3.


void printToPdf(const QString &filePath, PrintedPageSizeId pageSizeId, PrintedPageOrientation orientation)

Prints the WebEngineView's current content to a PDF document and stores it under filePath. The document's size will be determined by the value of pageSizeId and its orientation will be determined using orientation.

This QML method was introduced in QtWebEngine 1.3.


void reload()

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

See also reloadAndBypassCache().


void reloadAndBypassCache()

Reloads the current page, ignoring any cached content.

This QML method was introduced in QtWebEngine 1.1.

See also reload().


void replaceMisspelledWord(const QString &replacement)

Replace the current misspelled word with replacement.

This QML method was introduced in QtWebEngine 1.3.


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 finishes running.

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

The script will run in the same world as other scripts that are part of the loaded site.

Warning: Do not execute lengthy routines in the callback function, because it might block the rendering of the web content.

See WebEngineView::userScripts for an alternative API to inject scripts.


void setActiveFocusOnPress(bool arg)

Sets active focus to a clicked web engine view if arg is true. By setting it to false, a web engine view can be used to create a UI element that should not get focus. This can be useful in a hybrid UI.

This QML method was introduced in QtWebEngine 1.2.

See also activeFocusOnPressChanged().


void stop()

Stops loading the current page.


void triggerWebAction(WebAction action)

Triggers the web action action.

This QML method was introduced in QtWebEngine 1.2.

See also WebAction.


© 2016 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.