Qt WebView

Qt WebView provides a way to display web content in a QML application without necessarily including a full web browser stack by using native APIs where it makes sense.

This is useful on mobile platforms such as Android and iOS; On iOS the policy dictates that all web content is displayed using the operating system's web view.

On Windows and Linux, Qt WebView depends on the Qt WebEngine module to render content.

On macOS, the system web view is used in the same manner as iOS.

Prerequisites

To make the Qt WebView module function correctly across all platforms, it's necessary to call QtWebView::initialize() before creating the QGuiApplication instance and before window's QPlatformOpenGLContext is created.

Using The Module

QML API

The QML types in Qt WebView are available through the QtWebView import. To use the types, add the following import statement to your .qml file:

import QtWebView

C++ API

Using the C++ API requires linking against the module library, either directly or through other dependencies.

Building with CMake

Use the find_package() command to locate WebView component in the Qt6 package:

find_package(Qt6 COMPONENTS WebView)
target_link_libraries(target PUBLIC Qt::WebView)

For more information, see the Build with CMake overview page.

Building with qmake

Add the webview module to the QT variable in the project's .pro file:

QT += webview

Limitations

Due to platform limitations, overlapping the WebView with other QML components is not supported. Doing this will have unpredictable results which may differ from platform to platform.

Examples

Take a look at the Qt WebView Examples for a demonstration on how the APIs can be used in applications.

Licenses

Qt WebView is available under commercial licenses from The Qt Company. In addition, it is available under the GNU Lesser General Public License, version 3, or the GNU General Public License, version 2. See Qt Licensing for further details.

API Reference

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