QWebEngineProfile Class

The QWebEngineProfile class provides a web-engine profile shared by multiple pages. More...

Header: #include <QWebEngineProfile>
qmake: QT += webenginewidgets
Since: Qt 5.5
Inherits: QObject

Public Types

enum HttpCacheType { MemoryHttpCache, DiskHttpCache }
enum PersistentCookiesPolicy { NoPersistentCookies, AllowPersistentCookies, ForcePersistentCookies }

Public Functions

QWebEngineProfile(QObject * parent = 0)
QWebEngineProfile(const QString & storageName, QObject * parent = 0)
QString cachePath() const
void clearAllVisitedLinks()
void clearVisitedLinks(const QList<QUrl> & urls)
int httpCacheMaximumSize() const
HttpCacheType httpCacheType() const
QString httpUserAgent() const
bool isOffTheRecord() const
PersistentCookiesPolicy persistentCookiesPolicy() const
QString persistentStoragePath() const
QWebEngineScriptCollection * scripts() const
void setCachePath(const QString & path)
void setHttpCacheMaximumSize(int maxSize)
void setHttpCacheType(QWebEngineProfile::HttpCacheType httpCacheType)
void setHttpUserAgent(const QString & userAgent)
void setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy newPersistentCookiesPolicy)
void setPersistentStoragePath(const QString & path)
QWebEngineSettings * settings() const
QString storageName() const
bool visitedLinksContainsUrl(const QUrl & url) const
  • 31 public functions inherited from QObject


void downloadRequested(QWebEngineDownloadItem * download)

Static Public Members

QWebEngineProfile * defaultProfile()
  • 11 static public members inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 9 protected functions inherited from QObject

Detailed Description

The QWebEngineProfile class provides a web-engine profile shared by multiple pages.

QWebEngineProfile contains settings and history shared by all QWebEnginePages that belong to the profile.

A default profile is built-in that all web pages not specifically created with another profile belongs to.

Member Type Documentation

enum QWebEngineProfile::HttpCacheType

This enum describes the HTTP cache types QtWebEngine can be configured to use.

QWebEngineProfile::MemoryHttpCache0Use a in-memory cache. This is the only setting possible if off-the-record is set or no cache path is available.
QWebEngineProfile::DiskHttpCache1Use a disk cache. This is the default.

enum QWebEngineProfile::PersistentCookiesPolicy

This enum describes policy for cookie persistency.

QWebEngineProfile::NoPersistentCookies0Both session and persistent cookies are stored in memory. This is the only setting possible if off-the-record is set or no persistent data path is available.
QWebEngineProfile::AllowPersistentCookies1Cookies marked persistent are save and restored from disk, session cookies are only stored to disk for crash recovery. This is the default setting.
QWebEngineProfile::ForcePersistentCookies2Both session and persistent cookies are save and restored from disk.

Member Function Documentation

QWebEngineProfile::QWebEngineProfile(QObject * parent = 0)

Constructs a new off-the-record profile.

An off-the-record profile leaves no record on the local machine, and has no persistent data or cache. Thus, the HTTP cache can only be in memory and the cookies only be non-persistent, trying to change these settings will have no effect.

See also isOffTheRecord().

QWebEngineProfile::QWebEngineProfile(const QString & storageName, QObject * parent = 0)

Constructs a new profile with storage name storageName.

The storage name must be unique.

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

See also storageName().

QString QWebEngineProfile::cachePath() const

Returns the path used for caches.

By default this is below QStandardPaths::writableLocation(QStandardPaths::CacheLocation) in a storage name specific directory.

See also setCachePath(), storageName(), and QStandardPaths::writableLocation().

Clears all links from the visited links database.

See also clearVisitedLinks().

Clears the links in urls from the visited links database.

See also clearAllVisitedLinks().

[static] QWebEngineProfile * QWebEngineProfile::defaultProfile()

Returns the default profile.

The default profile uses the storage name "Default".

See also storageName().

[signal] void QWebEngineProfile::downloadRequested(QWebEngineDownloadItem * download)

This signal is emitted whenever a download has been triggered. The download argument holds the state of the download. The download either has to be explicitly accepted with QWebEngineDownloadItem::accept(), else the download will be cancelled by default. The download item is parented by the profile, but if not accepted will be deleted immediately after the signal emission. This signal can not be used with a queued connection.

This function was introduced in Qt 5.5.

See also QWebEngineDownloadItem.

int QWebEngineProfile::httpCacheMaximumSize() const

Returns the maximum size of the HTTP size.

Will return 0 if the size is automatically controlled by QtWebEngine.

See also setHttpCacheMaximumSize() and httpCacheType().

HttpCacheType QWebEngineProfile::httpCacheType() const

Returns the type of HTTP cache used.

If the profile is off-the-record MemoryHttpCache is returned.

See also setHttpCacheType() and cachePath().

QString QWebEngineProfile::httpUserAgent() const

Returns the user-agent string send with HTTP to identify the browser.

See also setHttpUserAgent().

bool QWebEngineProfile::isOffTheRecord() const

Returns true if this is an off-the-record profile that leaves no record on the computer.

This will force cookies and HTTP cache to be in memory, but also force all other normally persistent data to be stored in memory.

PersistentCookiesPolicy QWebEngineProfile::persistentCookiesPolicy() const

Returns the current policy for persistent cookies.

If the profile is off-the-record NoPersistentCookies is returned.

See also setPersistentCookiesPolicy().

QString QWebEngineProfile::persistentStoragePath() const

Returns the path used to store persistent data for the browser and web content.

Persistent data includes persistent cookies, HTML5 local storage and visited links.

By default this is below QStandardPaths::writableLocation(QStandardPaths::DataLocation) in a storage name specific directory.

See also setPersistentStoragePath(), storageName(), and QStandardPaths::writableLocation().

QWebEngineScriptCollection * QWebEngineProfile::scripts() const

Returns the script collection used by this profile.

See also QWebEngineScriptCollection.

void QWebEngineProfile::setCachePath(const QString & path)

Overrides the default path used for disk caches.

If set to the null string, the default path is restored.

See also cachePath().

void QWebEngineProfile::setHttpCacheMaximumSize(int maxSize)

Sets the maximum size of the HTTP cache to maxSize.

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

See also httpCacheMaximumSize() and setHttpCacheType().

void QWebEngineProfile::setHttpCacheType(QWebEngineProfile::HttpCacheType httpCacheType)

Sets the HTTP cache type to httpCacheType.

See also httpCacheType() and setCachePath().

void QWebEngineProfile::setHttpUserAgent(const QString & userAgent)

Overrides the default user-agent string, setting it to userAgent.

See also httpUserAgent().

void QWebEngineProfile::setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicy newPersistentCookiesPolicy)

Sets the policy for persistent cookies to newPersistentCookiesPolicy.

See also persistentCookiesPolicy().

void QWebEngineProfile::setPersistentStoragePath(const QString & path)

Overrides the default path used to store persistent web engine data.

If set to the null string, the default path is restored.

See also persistentStoragePath().

QWebEngineSettings * QWebEngineProfile::settings() const

Returns the default settings for all pages in this profile.

QString QWebEngineProfile::storageName() const

Returns the storage name for the profile.

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

bool QWebEngineProfile::visitedLinksContainsUrl(const QUrl & url) const

Returns true if url is considered a visited link by this profile.

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