QtWebEngine: A Comprehensive Guide to Setup and Use

Author

Reads 674

A sleek computer monitor displays video editing software in a modern workspace.
Credit: pexels.com, A sleek computer monitor displays video editing software in a modern workspace.

QtWebEngine is a powerful tool that allows you to embed a web browser into your Qt application. This means you can create desktop applications with web capabilities, such as displaying web pages or running web-based user interfaces.

To get started with QtWebEngine, you'll need to have Qt installed on your system. Qt is a cross-platform application development framework that provides a comprehensive set of libraries and tools for building applications.

The QtWebEngine module provides a C++ API for embedding a web browser into your Qt application. This API allows you to create a web browser view, which can be used to display web pages or run web-based user interfaces.

You can create a QtWebEngine browser view in your application's user interface by using the QWebEngineView class. This class provides a widget that displays a web page and allows users to interact with it.

Related reading: See Website Archive

Relationship to Chromium

Qt WebEngine uses code from the Chromium project, but it's not a complete copy of Chrome or Chromium.

Credit: youtube.com, What Is QtWebEngine And How Does It Work In PyQt? - Python Code School

Here are some key differences:

  • Binary files are stripped out
  • Auxiliary services that talk to Google platforms are removed, so there's no access to Google APIs like Google APIs
  • The code is fixed to build on other compilers than Google's special version of clang
  • The codebase is modularized to use system libraries like libpng, libjpeg, and others

Qt WebEngine updates to the latest Chromium version before a Qt release, and then applies some bug fixes and security patches afterwards. For Long Term Support (LTS) releases of Qt, Chromium might be updated again in a patch level release.

Introduction and Setup

QtWebEngine is a powerful tool for building web-based applications. It's a fork of the Chromium project, which is the same engine that powers Google Chrome.

You can install QtWebEngine using the Qt online installer or by downloading the QtWebEngine package from the Qt website.

The QtWebEngine module provides a set of APIs and tools for building web-based applications, including a web browser engine, JavaScript engine, and other supporting libraries.

Curious to learn more? Check out: Search Engine Scraping

Installation of

Let's get started with the installation process.

To begin with, you'll need to install qtwebengine by running the following commands.

This will get you set up for a smooth development experience.

You can install qtwebengine by running the command:

sudo apt-get install qtwebengine5-dev

This will ensure you have the necessary tools for your project.

Configuring

Credit: youtube.com, Introduction, setup and configuration.

Configuring is a crucial step in getting your system up and running. The default settings are usually set to ensure a smooth installation process, but you may need to adjust them to suit your specific needs.

The first thing to consider is the network settings, which can be found in the Network Configuration section. Here, you can set up the IP address, subnet mask, gateway, and DNS settings.

You can also configure the time zone, date, and time in the System Settings section. This is where you can ensure that your system is set to the correct time zone and date.

The user account settings can be found in the User Management section. Here, you can create new users, set passwords, and assign permissions.

Remember to save your changes regularly to avoid losing any progress.

A unique perspective: Web Camera Settings

Short Descriptions

In this section, we'll take a closer look at what's available to help you get started with your project.

Close-up view of a Facebook webpage interface in a browser window.
Credit: pexels.com, Close-up view of a Facebook webpage interface in a browser window.

The qtwebengine_convert_dict tool is a handy utility that converts hunspell dictionaries from the .dic format to the chromium format, which is .bdic.

You can use this tool to prepare your dictionaries for use with QtWebEngineProcess, which is a libexec program that runs a zygote process.

A zygote process is one that listens for spawn requests from a master process and will fork itself in response.

Here's a quick rundown of the tools we've discussed so far:

Alibaba Cloud

The Qt WebEngine QML implementation is similar to the Qt WebEngine Widgets implementation, but it doesn't have a separately accessible web engine page. This means the supported page functionality is integrated into the web engine view.

Readers also liked: Search Engine Cache

Core Features

Qt WebEngine Core provides an API shared by Qt WebEngine and Qt WebEngine Widgets for handling URL requests issued for the networking stack of Chromium and for accessing its HTTP cookies.

Qt WebEngine Core is based on the Chromium Project, which provides its own network and painting engines and is developed tightly together with its dependent modules. This version is based on Chromium version 94.0.4606, with additional security fixes from newer versions.

Implementing the QWebEngineUrlRequestInterceptor interface and installing the interceptor on a profile enables intercepting, blocking, and modifying URL requests (QWebEngineUrlRequestInfo) before they reach the networking stack of Chromium.

Architecture

Laptop with blockchain application interface connecting. Ideal for tech and crypto themes.
Credit: pexels.com, Laptop with blockchain application interface connecting. Ideal for tech and crypto themes.

The architecture of Qt WebEngine is quite interesting. Qt WebEngine is divided into three main modules: Qt WebEngine Widgets Module, Qt WebEngine Module, and Qt WebEngine Core Module.

These modules allow you to create different types of web applications, including widget-based and Qt Quick based web applications. The Qt WebEngine Core Module is responsible for interacting with Chromium.

The Qt WebEngine Process is a separate library that must be shipped with your application if you bundle the Qt libraries into it. This process is responsible for separating page rendering and JavaScript execution from the GUI process.

Widgets

Widgets are a fundamental part of any GUI application, and Qt WebEngine Widgets Module is no exception. It provides a main widget component called a web engine view, which can be used to load web content in various applications.

A web engine view is the main widget component of the Qt WebEngine module, and it can be used in various applications to load web content. Within a view, a web engine page holds a main frame that is responsible for web content, the history of navigated links, and actions.

Worth a look: Web Widget

A woman wearing virtual reality goggles interacting with a digital interface inside a modern space.
Credit: pexels.com, A woman wearing virtual reality goggles interacting with a digital interface inside a modern space.

The Qt WebEngine Widgets module uses the Qt Quick scene graph to compose the elements of a web page into one view, requiring OpenGL ES 2.0 or OpenGL 2.0 for its rendering.

You can use the QWebEngineView class to display web pages in the simplest way, as it is a widget that can be embedded into forms. This class has a QWebEnginePage, which can have a QWebEngineHistory and several QAction objects to apply actions on the web page.

Here are the key components of a QWebEnginePage:

  • QWebEngineHistory: provides access to the page's navigation history
  • QAction objects: apply actions on the web page
  • Ability to run JavaScript code in the context of the page's main frame
  • Ability to customize handlers for specific events like showing custom authentication dialogs

Each QWebEnginePage belongs to a QWebEngineProfile, which can have a QWebEngineSettings for specifying page settings, a QWebEngineScriptCollection for running scripts on the page, and a QWebEngineCookieStore for accessing the HTTP cookies of Chromium.

Core

The Qt WebEngine core is based on the Chromium Project, which provides its own network and painting engines and is developed tightly together with its dependent modules.

This version of Qt WebEngine is based on Chromium version 94.0.4606, with additional security fixes from newer versions. You can find the versions in the QtWebEngine sources in the CHROMIUM_VERSION file.

Google Browser on Laptop
Credit: pexels.com, Google Browser on Laptop

Qt WebEngine Core provides an API shared by Qt WebEngine and Qt WebEngine Widgets for handling URL requests issued for the networking stack of Chromium and for accessing its HTTP cookies.

Implementing the QWebEngineUrlRequestInterceptor interface and installing the interceptor on a profile enables intercepting, blocking, and modifying URL requests (QWebEngineUrlRequestInfo) before they reach the networking stack of Chromium.

A QWebEngineUrlSchemeHandler can be registered for a profile to add support for custom URL schemes. Requests for the scheme are then issued to QWebEngineUrlSchemeHandler::requestStarted() as QWebEngineUrlRequestJob objects.

The QWebEngineCookieStore class provides functions for accessing HTTP cookies of Chromium. The functions can be used to synchronize cookies with QNetworkAccessManager, as well as to set, delete, and intercept cookies during navigation.

Here are the different modules in Qt WebEngine:

  • Qt WebEngine Widgets Module for creating widget-based web applications
  • Qt WebEngine Module for creating Qt Quick based web applications
  • Qt WebEngine Core Module for interacting with Chromium

Each QWebEnginePage belongs to a QWebEngineProfile that can have a QWebEngineSettings for specifying page settings, a QWebEngineScriptCollection for running scripts on the page, and a QWebEngineCookieStore for accessing the HTTP cookies of Chromium. A QWebEnginePage can also directly point to a script collection.

Proxy Support

Black Samsung Tablet Display Google Browser on Screen
Credit: pexels.com, Black Samsung Tablet Display Google Browser on Screen

Proxy Support is a crucial feature for developers working with Qt WebEngine. It allows the application to use proxy settings from Qt Network, which are then forwarded to Chromium's networking stack.

If QNetworkProxy::applicationProxy is set, it will also be used for Qt WebEngine, giving you more control over the proxy configuration.

On macOS and Windows, Qt WebEngine automatically picks up the proxy configuration from the system, so you don't need to do anything extra.

On Linux, Qt WebEngine acknowledges settings from KDE and Gnome, making it easy to integrate with popular desktop environments.

If a proxy requires authentication, QWebEnginePage::proxyAuthenticationRequired is emitted, which can be handled differently depending on the application.

Codecs

Qt WebEngine supports the MPEG-4 Part 14 (MP4) file format only if the required proprietary audio and video codecs, such as H.264 and MPEG layer-3 (MP3), have been enabled.

Proprietary codecs can be enabled by passing the following option to the configure tool when configuring Qt. This is necessary for building Qt at the top level.

Two business professionals brainstorming and planning software development with a whiteboard in an office.
Credit: pexels.com, Two business professionals brainstorming and planning software development with a whiteboard in an office.

Support for proprietary codecs was added in Qt 5.6.0. This feature allows for the use of proprietary codecs like H.264 and MP3.

Warning: When distributing proprietary codec libraries, you must acquire licenses for them. This is a crucial step to avoid any potential issues.

FFmpeg is a cross-platform solution to record, convert, and stream audio and video. It can be configured for use with several codecs, which rises licensing issues during distribution with the codec libraries.

Open source implementations, such as OpenH264, are available for some codecs. This can be a viable alternative to proprietary codecs.

See what others are reading: Android as Web Camera

Drag and Drop

Qt WebEngine supports HTML5 drag and drop, allowing you to test this feature by opening an HTML5 drag and drop demo in Simple Browser or Nano Browser.

You can test the drag and drop feature by opening HTML5 Demos - Drag and Drop, HTML5 Demos - Simple Drag and Drop, or HTML5 Demos - Drag and Drop, Automatic Upload in Simple Browser or Nano Browser.

Dragging files into the browser is supported, but it's not part of HTML5 - you can test this feature by opening HTML5 Demos - File API.

Support for HTML5 drag and drop was added in Qt 5.13.0, and the feature was further improved in Qt 5.14.0.

Pdf File Viewing

A software developer engaged in coding on dual monitors in a modern office setting.
Credit: pexels.com, A software developer engaged in coding on dual monitors in a modern office setting.

Pdf File Viewing is a key feature in Qt WebEngine that allows users to view PDF documents by navigating to them.

This feature uses the Chromium extensions API and PDF viewer plugin to display the PDF documents. It can be tested in Simple Browser or Nano Browser.

To use this feature, loading plugins needs to be enabled using QWebEngineSettings::PluginsEnabled or WebEngineSettings::pluginsEnabled.

This feature can be turned on (default) or off via the QWebEngineSettings::PdfViewerEnabled or WebEngineSettings::pdfViewerEnabled setting.

Support for this feature was added in Qt 5.8.0.

Explore further: Html to Pdf Api

Page Lifecycle API

The Page Lifecycle API is a feature that allows user agents to reduce their resource consumption by freezing or discarding background pages. This is exposed in both the Widgets and QML APIs.

For example, the Page Lifecycle API specification includes two new DOM events, freeze and resume, which are fired when transitioning from the Active to the Frozen state and vice-versa. These events are connected to the lifecycleState property of the WebEngineView type.

Credit: youtube.com, Page Lifecycle API - HTTP203

The lifecycleState property controls the current lifecycle state of the web view, and it's allowed to freeze a web view that's currently playing music in the background, stopping the music. However, to implement a less aggressive resource-saving strategy that avoids interrupting user-visible background activity, the recommendedState property must be used.

The recommendedState property calculates a safe limit on the lifecycleState property, taking into account the current activity of the web view. This means that if the application wants to avoid interrupting background activity, it should avoid putting the web view into a more aggressively resource-saving lifecycle state than what's given by recommendedState.

Print To Pdf

Print to PDF is a powerful feature that allows you to save web pages as PDF files.

You can use Qt WebEngine to print a web page to a PDF file with the help of QWebEnginePage::printToPdf() and WebEngineView.printToPdf.

This feature can be tested using Html2Pdf.

Process Models

Qt WebEngine uses multiple OS processes to isolate web sites from each other and from the client application, improving security and robustness.

A smartphone displays the ChatGPT interface on its screen, symbolizing modern AI technology.
Credit: pexels.com, A smartphone displays the ChatGPT interface on its screen, symbolizing modern AI technology.

There are three process models supported by Qt WebEngine: Process per Site Instance, Process per Site, and Single Process.

Each process model has its own benefits and trade-offs. For example, Process per Site Instance can provide better security by isolating each instance of a web site, but it can also lead to increased resource usage.

The choice of process model depends on the specific needs of your application. If you need to render multiple web sites simultaneously, Process per Site may be a better choice. If you're concerned about security and can afford the extra resource usage, Process per Site Instance could be the way to go.

Here are the three process models in a table for easy reference:

The Qt WebEngine Process is a separate executable that is used to render web pages and execute JavaScript, and it's used in conjunction with these process models to improve security and robustness.

Spellchecker

The spellchecker in Qt WebEngine is a powerful tool that helps users submit spellchecked messages. It integrates spellchecking support into HTML forms, allowing users to select from up to four suggestions when clicking on an underlined misspelled word.

Hands typing code on a laptop in a workspace. Indoor setting focused on software development.
Credit: pexels.com, Hands typing code on a laptop in a workspace. Indoor setting focused on software development.

To enable spellchecking, you'll need to set up dictionaries from the Hunspell project. These dictionaries consist of two files: a .dic file containing words for the language and an .aff file defining special flags. You can convert these files into the bdic format using the qwebengine_convert_dict tool.

The spellchecker will look for dictionaries in specific locations, which can be customized by setting the QTWEBENGINE_DICTIONARIES_PATH environment variable. If it's not set, the spellchecker will use the qtwebengine_dictionaries directory relative to the executable.

On macOS, there are two possible configurations for spellchecking data: Hunspell dictionaries and native dictionaries. If Hunspell dictionaries are used, the spellchecker will look in the qtwebengine_dictionaries subdirectory inside the application bundle Resources directory.

Here are the paths the spellchecker considers when looking for dictionaries:

  • QTWEBENGINE_DICTIONARIES_PATH, if set
  • QCoreApplication::applicationDirPath()/qtwebengine_dictionaries or QCoreApplication::applicationDirPath()/../Contents/Resources/qtwebengine_dictionaries (on macOS)
  • [QLibraryInfo::DataPath]/qtwebengine_dictionaries or path/to/QtWebEngineCore.framework/Resources/qtwebengine_dictionaries (Qt framework bundle on macOS)

Spellchecking is disabled by default, but can be enabled per profile using the QWebEngineProfile::setSpellCheckEnabled() method in widget-based applications or the WebEngineProfile.spellCheckEnabled property in Qt Quick applications.

Favicon Handling

Credit: youtube.com, 2.4 Adding Favicon

Favicon Handling is a key feature in this system, allowing you to access icons with ease.

A QQuickImageProvider is registered for accessing icons, which can be accessed by a special URL with the scheme "image:" and the host "favicon".

You can use this URL to access the favicon of a webpage, for example, by replacing the URL with the actual favicon URL.

If you want to access the icon of a specific page, you can use the page's URL instead, like in the example.

If you have multiple icons available, you can choose the one with the desired size by specifying the Image::sourceSize property.

The largest available icon will be chosen if Image::sourceSize is not specified or set to 0.

The system looks up the requested icon in the existing WebEngineView instances, first trying to match the currently displayed icons.

If no match is found, it requests the icon from the database, which is stored in the persistent storage and can be accessed without a network connection.

Each profile has its own icon database, which is stored separately and can be accessed independently.

Note that the icon database is not available for off-the-record profiles, so you won't be able to access icons in those cases.

See what others are reading: Webp Example

Embedding Web Content

Credit: youtube.com, Why Use QtWebEngine For Web Content In PyQt Applications? - Python Code School

Embedding web content into your Qt application is a breeze with Qt WebEngine. You can use the QWebEngineView class to display web pages in the simplest way, and it's a widget, so you can embed it into your forms.

To get started, you'll need to initialize the web engine, which is automatically done for widget-based applications, unless it's placed in a plugin. In that case, you'll need to initialize it in the application main source file using QtWebEngineQuick::initialize.

The QWebEngineView class has one QWebEnginePage, which has a QWebEngineHistory that provides access to the page's navigation history. You can also run JavaScript code in the context of the page's main frame and customize handlers for specific events.

A QWebEnginePage belongs to a QWebEngineProfile, which can have a QWebEngineSettings for specifying page settings, a QWebEngineScriptCollection for running scripts on the page, and a QWebEngineCookieStore for accessing the HTTP cookies of Chromium.

For Qt Quick applications, you can use the WebEngineView QML type to render regions of dynamic web content. This type can share the screen with other QML types or encompass the full screen.

On a similar theme: Content Protection Network

Credit: youtube.com, QtWebEngine Technology Preview

To ensure OpenGL context sharing between the GUI and render processes, you'll need to initialize the web engine using QtWebEngineQuick::initialize in the application main source file.

You can load pages into the WebEngineView using either an URL or HTML string, and navigate within session history. 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.

A web engine view is the main widget component of the Qt WebEngine module, and it can be used in various applications to load web content. It holds a web engine page, which has a main frame responsible for web content, history, and actions.

Security and Certificates

Qt WebEngine uses its own network stack, which means you can't use QSslConfiguration to open SSL connections. Instead, it relies on the root CA certificates from the operating system to validate the peer's certificate.

Credit: youtube.com, QtWS15- QtWebEngine – Taming the beast, Kai Köhne, The Qt Company

The WebEngineCertificateError::error and QWebEngineCertificateError::Type enumerations provide information about the types of certificate errors that might occur. These errors can be handled using the WebEngineView::certificateError QML method.

You can also use the QWebEnginePage::certificateError signal to catch certificate errors, but you'll need to reimplement the function to handle them. This approach gives you more control over how to handle certificate errors in your application.

Here's an interesting read: Soft 404 Errors

Advanced Features

QtWebEngine offers advanced features that make it a powerful tool for web development. You can run JavaScript code in the context of the page's main frame using a QWebEnginePage.

A QWebEnginePage can have a QWebEngineHistory that provides access to the page's navigation history. This feature is particularly useful for building applications that require users to navigate through multiple web pages.

Each QWebEnginePage belongs to a QWebEngineProfile, which can have a QWebEngineSettings for specifying page settings. This allows you to customize the behavior of the web engine to suit your application's needs.

Custom Schemes

Credit: youtube.com, Jieshuo Operation Settings Part 3 | Custom Gesture Schemes & Per-App Gesture Options

Custom schemes in Qt WebEngine allow applications to define their own URL schemes with specialized security policies and transport mechanisms. This can be useful for implementing alternative network protocols.

You can use custom schemes to create privileged internal schemes for displaying user interface components or debugging information. This is a great way to add a layer of security to your application.

Custom schemes can also be used to create sandboxed schemes with extra restrictions. This can be helpful when working with sensitive data or integrating with other applications.

For more information on custom schemes, see QWebEngineUrlScheme and QWebEngineUrlSchemeHandler. These classes provide a way to define and handle custom URL schemes in your application.

By using custom schemes, you can create a more secure and flexible application that meets the needs of your users.

Html5 Drm

HTML5 DRM is supported by Qt WebEngine, which can view DRM protected videos if the Widevine CDM plugin is installed.

Credit: youtube.com, DRM-X 4.0 Media Encryption System Video Demo

The Widevine CDM plugin is a replacement for Flash based plugins and comes in a binary format, hiding DRM decryption implementation details. It can be obtained from a third party or from a Google Chrome installation.

Qt WebEngine looks for the Widevine CDM plugin in well-known locations, such as the default Google Chrome installation directory or Linux distro specific paths.

The video format most commonly used by DRM services is H.264, which requires proprietary audio and video codecs.

On Windows, you can enable these codecs to view DRM-protected videos.

Html5 Geolocation

Html5 Geolocation is a powerful feature that allows your application to determine the user's location.

Qt WebEngine supports the JavaScript Geolocation API with Qt Positioning as a backend.

The application has to explicitly allow the feature by using QWebEnginePage::Geolocation or WebEngineView.Feature.

If Qt Positioning has been built before Qt WebEngine, this feature can be tested by using Maps and allowing it to find the current position of the user.

Note that on Windows an external GPS receiver must be connected to the application.

For more information, see Qt Positioning.

Http/2 Protocol

Credit: youtube.com, Browser to Server Journey Explained | What Happens When You Hit a URL?Explained(DNS, TCP, TLS, HTTP)

Qt WebEngine supports the Chromium implementation of the HTTP/2 protocol. This allows for faster and more efficient data transfer between the browser and the server.

You can test this feature by opening an HTTP/2 demo, such as the Akamai HTTP/2 Demo, in Simple Browser or Nano Browser.

Pepper Plugin API

To enable Pepper Plugin API plugins, you need to set WebEngineSettings::pluginsEnabled or QWebEngineSettings::PluginsEnabled to true.

The plugins must be loaded manually using the Chromium command line syntax with the --register-pepper-plugins argument. This argument value is a list of entries, separated by commas, that contain the file path and one or several MIME types, separated by semicolons.

For example, the MIME type is important because it determines which embeds the plugin is used for. The file path and MIME types are separated by semicolons.

Intriguing read: Compiled Html File

The Page Lifecycle API specification is a work-in-progress extension to the HTML standard that allows user agents to reduce resource consumption by freezing or discarding background pages.

Close-up view of a Facebook webpage displayed on a browser with social media icons.
Credit: pexels.com, Close-up view of a Facebook webpage displayed on a browser with social media icons.

This feature is exposed in both the Widgets and QML APIs, and can be seen in action with the WebEngine Lifecycle Example.

The lifecycleState property of the WebEngineView type controls the current lifecycle state of the web view, and can be transitioned to various states with few restrictions.

However, to implement a less aggressive resource-saving strategy that avoids interrupting user-visible background activity, the recommendedState property must be used.

The recommendedState property calculates a safe limit on the lifecycleState property, taking into account the current activity of the web view.

For example, if a web view is playing music in the background, the recommended state will be Active, as a more aggressive state would stop the music.

The lifecycleState property is connected to the Page Lifecycle API specification, which specifies two new DOM events, freeze and resume, and adds a new Document.wasDiscarded boolean property.

The freeze and resume events are fired when transitioning from the Active to the Frozen state, and vice-versa.

The Document.wasDiscarded property is set to true when transitioning from the Discarded state to the Active state.

To avoid interrupting background activity, an application should avoid putting the web view into a more aggressively resource-saving lifecycle state than what's given by recommendedState.

Web Notifications

Credit: youtube.com, Notifications Advanced Features

Web notifications can be a powerful way to engage users and keep them informed, but they do require explicit permission from the application.

To enable web notifications, you'll need to use the QWebEnginePage::Notifications or WebEngineView.Notifications feature, as required by Qt WebEngine.

This means you have control over when and how notifications are displayed, giving you a way to tailor the user experience to your application's needs.

By following this approach, you can ensure that users are only notified when it's relevant and useful to them, rather than being bombarded with unnecessary messages.

This is an important consideration, as excessive notifications can quickly become annoying and even lead to users disabling them altogether.

Platform Specifics

Qt WebEngine is a powerful tool, but it does come with some platform-specific requirements.

Currently, Qt WebEngine only supports Windows, Linux, and macOS operating systems.

You'll also need a newer compiler than the rest of Qt, due to Chromium build requirements.

Process

Hand holding smartphone with tech interface on screen
Credit: pexels.com, Hand holding smartphone with tech interface on screen

Qt WebEngine uses multiple OS processes to isolate web sites from each other and from the client application, improving security and robustness.

This is achieved through different process models, which determine how web sites are divided between OS processes. The supported process models are Process per Site Instance, Process per Site, and Single Process.

Pages from separate sites are put into separate processes, while pages from the same site share a process. This is similar to the same-origin policy, but subdomains are ignored.

For example, https://en.wikipedia.org/ and https://de.wikipedia.org/ would belong to the same site, but https://en.wikipedia.org and https://www.en.wikipedia.org would be in separate processes.

The Process per Site Instance model is the default, where each site instance is a collection of web pages belonging to the same site.

Here are the supported process models:

The Qt WebEngine Process is a separate executable that is used to render web pages and execute JavaScript, mitigating security issues and isolating crashes caused by specific content.

High Dpi Support

Credit: youtube.com, Windows : Automatic rescaling of an application on high-dpi Windows platform?

High DPI Support is crucial for ensuring your application looks great on high-resolution monitors. To enable automatic scaling based on the monitor's pixel density, set the Qt::AA_EnableHighDpiScaling attribute.

Qt WebEngine applications are affected by the scaling, which impacts the default zooming factor and scrollbar size. This means your application's UI will adapt to the user's screen resolution.

Qt WebEngine bundles images for normal and high-dpi resolutions into two files: qtwebengine_resources_100p.pak and qtwebengine_resources_200p.pak. These files need to be deployed depending on the target resolutions.

The qtwebengine_resources_100p.pak file likely contains images for normal resolution, while the qtwebengine_resources_200p.pak file contains images for high-dpi resolution.

Discover more: Index Htm File

Platform Notes

Qt WebEngine only supports Windows, Linux, and macOS, which might limit your deployment options.

The platform requirements for Qt WebEngine are quite specific, often necessitating a newer compiler than what's used for the rest of Qt.

You'll need to check out Qt WebEngine Platform Notes for more detailed information on these requirements.

A Close-Up Shot of a Terminal
Credit: pexels.com, A Close-Up Shot of a Terminal

The documentation and licensing for Qt WebEngine are handled under the terms of the GNU Free Documentation License version 1.3, courtesy of the Free Software Foundation.

Qt is a trademark of The Qt Company Ltd. in Finland and other countries worldwide, so be mindful of that when using the name.

Patricia Dach

Junior Copy Editor

Patricia Dach is a meticulous and detail-oriented Copy Editor with a passion for refining written content. With a keen eye for grammar and syntax, she ensures that articles are polished and error-free. Her expertise spans a range of topics, from technology to lifestyle, and she is well-versed in various style guides.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.