WebView QML Type

A component for displaying web content More...

Import Statement: import QtWebView 1.0



Detailed Description

WebView is a component for displaying web content which is implemented using native APIs on the platforms where this is available, thus it does not necessarily require including a full web browser stack as part of the application.

Note: Due to platform limitations overlapping the WebView and other QML components is not supported.

Property Documentation

canGoBack : bool

True if it's currently possible to navigate back in the web history.

canGoForward : bool

True if it's currently possible to navigate forward in the web history.

loadProgress : int

The current load progress of the web content, represented as an integer between 0 and 100.

loading : bool

True if the WebView is currently in the process of loading new content, and false if not.

title : string

The title of the currently loaded web page.

url : url

The url of currently loaded web page. Changing this will trigger loading new content.

The url is used as-is. Urls that originate from user input should be parsed with QUrl::fromUserInput.

Method Documentation

void goBack()

Navigates back in the web history.

void goForward()

Navigates forward in the web history.

void loadHtml(string html, url baseUrl)

Loads the specified html content to 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 QtWebView::WebView::url.

void reload()

Reloads the current url.

void runJavaScript(string script, variant callback)

Runs the specified JavaScript. 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 url.

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