WebEngineProfile QML Type | Qt WebEngine 5.8

Qt 5.8 | Qt WebEngine | QML Types | WebEngineProfile QML Type

Qt 5.8.0 Reference Documentation

# WebEngineProfile QML Type

Contains settings, scripts, and visited links common to multiple web engine views. More...

Import Statement: | import QtWebEngine 1.4
Since: | QtWebEngine 1.1
Instantiates: | QQuickWebEngineProfile

- List of all members, including inherited members

## Properties

- cachePath : string
- httpAcceptLanguage : string
- httpCacheMaximumSize : int
- httpCacheType : enumeration
- httpUserAgent : string
- offTheRecord : bool
- persistentCookiesPolicy : enumeration
- persistentStoragePath : string
- spellCheckEnabled : bool
- spellCheckLanguages : list<string>
- storageName : string

## Signals

- downloadFinished(WebEngineDownloadItem download)
- downloadRequested(WebEngineDownloadItem download)

## Methods

- void clearHttpCache()

## Detailed Description

WebEngineProfile contains settings, scripts, and the list of visited links shared by all views that belong to the profile. As such, profiles can be used to isolate views from each other. A typical use case is a dedicated profile for a 'private browsing' mode.

Each web engine view has an associated profile. Views that do not have a specific profile set share a common default one.

## Property Documentation

cachePath : string

The path to the location where the profile's caches are stored, in particular the HTTP cache.

By default, the caches are stored below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a directory named using storageName.

httpAcceptLanguage : string

The value of the Accept-Language HTTP request-header field.

This QML property was introduced in QtWebEngine 1.2.

httpCacheMaximumSize : int

The maximum size of the HTTP cache. If `0`, the size will be controlled automatically by QtWebEngine. The default value is `0`.

See also httpCacheType.

httpCacheType : enumeration

This enumeration describes the type of the HTTP cache:

Constant | Description
--- | ---
`WebEngineProfile.MemoryHttpCache` | Uses an in-memory cache. This is the only setting possible if offTheRecord is set or no persistentStoragePath is available.
`WebEngineProfile.DiskHttpCache` | Uses a disk cache. This is the default value.
`WebEngineProfile.NoCache` | Disables caching. (Added in 5.7)

httpUserAgent : string

The user-agent string sent with HTTP to identify the browser.

offTheRecord : bool

Whether the web engine profile is off-the-record. An off-the-record profile forces cookies, the HTTP cache, and other normally persistent data to be stored only in memory.

persistentCookiesPolicy : enumeration

This enumeration describes the policy of cookie persistency:

Constant | Description
--- | ---
`WebEngineProfile.NoPersistentCookies` | Both session and persistent cookies are stored in memory. This is the only setting possible if offTheRecord is set or no persistentStoragePath is available.
`WebEngineProfile.AllowPersistentCookies` | Cookies marked persistent are saved to and restored from disk, whereas session cookies are only stored to disk for crash recovery. This is the default setting.
`WebEngineProfile.ForcePersistentCookies` | Both session and persistent cookies are saved to and restored from disk.

persistentStoragePath : string

The path to the location where the persistent data for the browser and web content are stored. Persistent data includes persistent cookies, HTML5 local storage, and visited links.

By default, the storage is located below QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a directory named using storageName.

spellCheckEnabled : bool

This property holds whether the web engine spell checker is enabled.

This QML property was introduced in QtWebEngine 1.4.

spellCheckLanguages : list<string>

This property holds the list of languages used by the spell checker. Each language should match the name of the `.bdic` dictionary. For example, the language `en-US` will load the `en-US.bdic` dictionary file.

Qt WebEngine checks for the `qtwebengine_dictionaries` subdirectory first in the local directory and if it is not found, in the Qt installation directory.

On macOS, depending on how Qt WebEngine is configured at build time, there are two possibilities how spellchecking data is found:

- Hunspell dictionaries (default) - .bdic dictionaries are used, just like on other platforms
- Native dictionaries - the macOS spellchecking APIs are used (which means the results will depend on the installed OS dictionaries)

Thus, in the macOS Hunspell case, Qt WebEngine will look in the qtwebengine_dictionaries subdirectory located inside the application bundle `Resources` directory, and also in the `Resources` directory located inside the Qt framework bundle.

To summarize, in case of Hunspell usage, the following paths are considered:

- 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)

For more information about how to compile `.bdic` dictionaries, see the Spellchecker Example.

This QML property was introduced in QtWebEngine 1.4.

storageName : string

The storage name that is used to create separate subdirectories for each profile that uses the disk for storing persistent data and cache.

See also WebEngineProfile::persistentStoragePath and WebEngineProfile::cachePath.

## Signal Documentation

downloadFinished(WebEngineDownloadItem download)

This signal is emitted whenever downloading stops, because it finished successfully, was cancelled, or was interrupted (for example, because connectivity was lost). The download argument holds the state of the finished download instance.

downloadRequested(WebEngineDownloadItem download)

This signal is emitted whenever a download has been triggered. The download argument holds the state of the download. The download has to be explicitly accepted with WebEngineDownloadItem::accept() or the download will be cancelled by default.

## Method Documentation

void clearHttpCache()

Removes the profile's cache entries.

This QML method was introduced in QtWebEngine 1.3.

See also WebEngineProfile::cachePath.