- Qt 6.9
- Qt WebEngine
- C++ Classes
- QtWebEngineCore
- QWebEngineProfileBuilder
- Qt 6.9.3 Reference Documentation

# QWebEngineProfileBuilder Class

The QWebEngineProfileBuilder class provides a way to construct QWebEngineProfile. More...

Header: | `#include <QWebEngineProfileBuilder>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS WebEngineCore)` `target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore)`
qmake: | `QT += webenginecore`
Since: | Qt 6.9

- List of all members, including inherited members

## Public Functions

QWebEngineProfile * | createProfile(const QString &storageName, QObject *parent = nullptr) const
QWebEngineProfileBuilder & | setCachePath(const QString &path)
QWebEngineProfileBuilder & | setHttpCacheMaximumSize(int maxSizeInBytes)
QWebEngineProfileBuilder & | setHttpCacheType(QWebEngineProfile::HttpCacheType httpCacheType)
QWebEngineProfileBuilder & | setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy persistentCookiePolicy)
QWebEngineProfileBuilder & | setPersistentPermissionsPolicy(QWebEngineProfile::PersistentPermissionsPolicy persistentPermissionPolicy)
QWebEngineProfileBuilder & | setPersistentStoragePath(const QString &path)

## Static Public Members

QWebEngineProfile * | createOffTheRecordProfile(QObject *parent = nullptr)

## Detailed Description

A QWebEngineProfileBuilder creates an instance of QWebEngineProfile class. Some profile's properties have to be initialized in one call and should not be modified during profile lifetime. The web engine profile builder simply guards that.

## Member Function Documentation

### `[static]` QWebEngineProfile *QWebEngineProfileBuilder::createOffTheRecordProfile(QObject *parent = nullptr)

Creates an off-the-record profile with the parent object parent that leaves no record on the local machine and has no persistent data or cache. This will force cookies, persistent data and HTTP cache to be stored in memory

### QWebEngineProfile *QWebEngineProfileBuilder::createProfile(const QString &storageName, QObject *parent = nullptr) const

Constructs a profile with the storage name storageName and parent parent.

The storage name is used to give each disk-based profile, a separate subdirectory for persistent data and cache. The storage location must be unique during application life time. It is up to the user to prevent the creation of profiles with same storage's location, which can lead to corrupted browser cache.

A disk-based QWebEngineProfile should be destroyed before the application exit, otherwise the cache and persistent data may not be fully flushed to disk.

Note: When creating a disk-based profile, if the data path is already in use by another profile, the function will return a null pointer.

See also QWebEngineProfile::storageName().

### QWebEngineProfileBuilder &QWebEngineProfileBuilder::setCachePath(const QString &path)

Sets the path used for the cache to path.

By default, this is below StandardPaths::CacheLocation in a QtWebengine/StorageName specific subdirectory.

Note: Use QStandardPaths::writableLocation(QStandardPaths::CacheLocation) to obtain the QStandardPaths::CacheLocation path.

See also QWebEngineProfile::cachePath() and QStandardPaths::writableLocation().

### QWebEngineProfileBuilder &QWebEngineProfileBuilder::setHttpCacheMaximumSize(int maxSizeInBytes)

Sets the maximum size of the HTTP cache to maxSizeInBytes bytes.

Setting it to `0` means the size will be controlled automatically by QtWebEngine.

See also QWebEngineProfile::httpCacheMaximumSize() and setHttpCacheType().

### QWebEngineProfileBuilder &QWebEngineProfileBuilder::setHttpCacheType(QWebEngineProfile::HttpCacheType httpCacheType)

Sets the HTTP cache type to httpCacheType.

See also QWebEngineProfile::httpCacheType() and setCachePath().

### QWebEngineProfileBuilder &QWebEngineProfileBuilder::setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy persistentCookiePolicy)

Sets the policy for persistent cookies to persistentCookiePolicy.

See also QWebEngineProfile::persistentCookiesPolicy().

### QWebEngineProfileBuilder &QWebEngineProfileBuilder::setPersistentPermissionsPolicy(QWebEngineProfile::PersistentPermissionsPolicy persistentPermissionPolicy)

Sets the policy for persistent permissions to persistentPermissionPolicy.

See also QWebEngineProfile::persistentPermissionsPolicy().

### QWebEngineProfileBuilder &QWebEngineProfileBuilder::setPersistentStoragePath(const QString &path)

Sets the path used to store persistent data for the browser and web content to path. Persistent data includes persistent cookies, HTML5 local storage, and visited links.

By default, this is below QStandardPaths::DataLocation in a QtWebengine/StorageName specific subdirectory.

Note: Use QStandardPaths::writableLocation(QStandardPaths::DataLocation) to obtain the QStandardPaths::DataLocation path.

See also QWebEngineProfile::persistentStoragePath() and QStandardPaths::writableLocation().