Qt WebKit

The Qt WebKit module provides the WebView API which allows QML applications to render regions of dynamic web content. A WebView component may share the screen with other QML components or encompass the full screen as specified within the QML application.

QML WebView version 3.0 is incompatible with previous QML WebView API versions. It allows an application to load pages into the WebView, either by URL or with an HTML string, and navigate within session history. By default, links to different pages load within the same WebView, but applications may intercept requests to delegate links to other functions.

The following sample QML application loads a web page, responds to session history context, and intercepts requests for external links. It also makes use of ScrollView from Qt Quick Controls to add scroll bars for the content area.

import QtQuick 2.0
import QtQuick.Controls 1.0
import QtWebKit 3.0

ScrollView {
    width: 1280
    height: 720
    WebView {
        id: webview
        url: "http://qt-project.org"
        anchors.fill: parent
        onNavigationRequested: {
            // detect URL scheme prefix, most likely an external link
            var schemaRE = /^\w+:/;
            if (schemaRE.test(request.url)) {
                request.action = WebView.AcceptRequest;
            } else {
                request.action = WebView.IgnoreRequest;
                // delegate request.url here


There are several Qt WebKit examples located in the Qt WebKit Examples page.

Notes provided by the Qt Community

No notes