WebEngine Widgets Minimal Example

Displays a web page using Qt WebEngine Widgets.


** WebEngine Widgets Minimal Example demonstrates how to use QWebEngineView to render a web page. It shows the minimum amount of code needed to load and display an HTML page, and can be used as a basis for further experimentation.

Running the Example

To run the example from Qt Creator , open the Welcome mode and select the example from Examples. For more information, visit Building and Running an Example.

The Code

We first define a commandLineUrlArgument function that returns the URL to open. This is either the first positional argument given on the command line, or https://www.qt.io as a fallback.

In the main function we first set the organizationName property. This affects the locations where Qt WebEngine stores persistent and cached data (see also cachePath and persistentStoragePath ).

Next, we instantiate a QApplication and a QWebEngineView . The URL to load is taken from commandLineUrlArgument and loaded by calling setUrl . The view widget is given a reasonable default size, and shown. Finally, exec() launches the main event loop.


The example requires a working internet connection to render the Qt Homepage. An optional system proxy should be picked up automatically. However, for proxies that require a username or password, you need to connect to proxyAuthenticationRequired .

Qt WebEngine Widgets uses the Qt Quick Scene Graph to compose the page. Therefore, OpenGL support is required.

Example project @ code.qt.io