QQuickWebEngineProfile Class
The QQuickWebEngineProfile class provides a web engine profile shared by multiple pages. More...
Header: | #include <QQuickWebEngineProfile> |
Since: | Qt 5.6 |
Instantiated By: | WebEngineProfile |
Inherits: | QObject |
Public Types
enum | HttpCacheType { MemoryHttpCache, DiskHttpCache, NoCache } |
enum | PersistentCookiesPolicy { NoPersistentCookies, AllowPersistentCookies, ForcePersistentCookies } |
Properties
|
|
- 1 property inherited from QObject
Public Functions
QQuickWebEngineProfile(QObject *parent = Q_NULLPTR) | |
QString | cachePath() const |
void | clearHttpCache() |
QWebEngineCookieStore * | cookieStore() const |
QString | httpAcceptLanguage() const |
int | httpCacheMaximumSize() const |
HttpCacheType | httpCacheType() const |
QString | httpUserAgent() const |
void | installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler) |
bool | isOffTheRecord() const |
bool | isSpellCheckEnabled() const |
PersistentCookiesPolicy | persistentCookiesPolicy() const |
QString | persistentStoragePath() const |
void | removeAllUrlSchemeHandlers() |
void | removeUrlScheme(const QByteArray &scheme) |
void | removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler) |
void | setCachePath(const QString &path) |
void | setHttpAcceptLanguage(const QString &httpAcceptLanguage) |
void | setHttpCacheMaximumSize(int maxSize) |
void | setHttpCacheType(QQuickWebEngineProfile::HttpCacheType) |
void | setHttpUserAgent(const QString &userAgent) |
void | setOffTheRecord(bool offTheRecord) |
void | setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy) |
void | setPersistentStoragePath(const QString &path) |
void | setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor) |
void | setSpellCheckEnabled(bool enabled) |
void | setSpellCheckLanguages(const QStringList &languages) |
void | setStorageName(const QString &name) |
QStringList | spellCheckLanguages() const |
QString | storageName() const |
const QWebEngineUrlSchemeHandler * | urlSchemeHandler(const QByteArray &scheme) const |
- 31 public functions inherited from QObject
Signals
void | cachePathChanged() |
void | downloadFinished(QQuickWebEngineDownloadItem *download) |
void | downloadRequested(QQuickWebEngineDownloadItem *download) |
void | httpAcceptLanguageChanged() |
void | httpCacheMaximumSizeChanged() |
void | httpCacheTypeChanged() |
void | httpUserAgentChanged() |
void | offTheRecordChanged() |
void | persistentCookiesPolicyChanged() |
void | persistentStoragePathChanged() |
void | spellCheckEnabledChanged() |
void | spellCheckLanguagesChanged() |
void | storageNameChanged() |
- 2 signals inherited from QObject
Static Public Members
QQuickWebEngineProfile * | defaultProfile() |
- 11 static public members inherited from QObject
Additional Inherited Members
Detailed Description
The QQuickWebEngineProfile class provides a web engine profile shared by multiple pages.
A web engine profile contains properties and functionality shared by a group of web engine pages.
Information about visited links is stored together with persistent cookies and other persistent data in a storage described by the persistentStoragePath property.
Profiles can be used to isolate pages from each other. A typical use case is a dedicated off-the-record profile for a private browsing mode. An off-the-record profile forces cookies, the HTTP cache, and other normally persistent data to be stored only in memory. The offTheRecord property holds whether a profile is off-the-record.
The default profile can be accessed by defaultProfile(). It is a built-in profile that all web pages not specifically created with another profile belong to.
A WebEngineProfile instance can be created and accessed from C++ through the QQuickWebEngineProfile class, which exposes further functionality in C++. This allows Qt Quick applications to intercept URL requests (QQuickWebEngineProfile::setRequestInterceptor), or register custom URL schemes (QQuickWebEngineProfile::installUrlSchemeHandler).
Spellchecking HTML form fields can be enabled per profile by setting the spellCheckEnabled property and the current languages used for spellchecking can be set by using the spellCheckLanguages property.
Member Type Documentation
enum QQuickWebEngineProfile::HttpCacheType
This enum describes the HTTP cache type:
Constant | Value | Description |
---|---|---|
QQuickWebEngineProfile::MemoryHttpCache | 0 | Use an in-memory cache. This is the only setting possible if off-the-record is set or no cache path is available. |
QQuickWebEngineProfile::DiskHttpCache | 1 | Use a disk cache. This is the default. |
QQuickWebEngineProfile::NoCache | 2 | Disable both in-memory and disk caching. (Added in Qt 5.7) |
enum QQuickWebEngineProfile::PersistentCookiesPolicy
This enum describes policy for cookie persistency:
Constant | Value | Description |
---|---|---|
QQuickWebEngineProfile::NoPersistentCookies | 0 | Both 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. |
QQuickWebEngineProfile::AllowPersistentCookies | 1 | 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. |
QQuickWebEngineProfile::ForcePersistentCookies | 2 | Both session and persistent cookies are saved to and restored from disk. |
Property Documentation
cachePath : QString
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.
Access functions:
QString | cachePath() const |
void | setCachePath(const QString &path) |
Notifier signal:
void | cachePathChanged() |
httpAcceptLanguage : QString
The value of the Accept-Language HTTP request-header field.
Access functions:
QString | httpAcceptLanguage() const |
void | setHttpAcceptLanguage(const QString &httpAcceptLanguage) |
Notifier signal:
void | httpAcceptLanguageChanged() |
httpCacheMaximumSize : int
The maximum size of the HTTP cache. If 0
, the size will be controlled automatically by QtWebEngine. The default value is 0
.
Access functions:
int | httpCacheMaximumSize() const |
void | setHttpCacheMaximumSize(int maxSize) |
Notifier signal:
void | httpCacheMaximumSizeChanged() |
See also httpCacheType.
httpCacheType : HttpCacheType
This enumeration describes the type of the HTTP cache.
If the profile is off-the-record, MemoryHttpCache is returned.
Access functions:
HttpCacheType | httpCacheType() const |
void | setHttpCacheType(QQuickWebEngineProfile::HttpCacheType) |
Notifier signal:
void | httpCacheTypeChanged() |
httpUserAgent : QString
The user-agent string sent with HTTP to identify the browser.
Access functions:
QString | httpUserAgent() const |
void | setHttpUserAgent(const QString &userAgent) |
Notifier signal:
void | httpUserAgentChanged() |
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.
Access functions:
bool | isOffTheRecord() const |
void | setOffTheRecord(bool offTheRecord) |
Notifier signal:
void | offTheRecordChanged() |
persistentCookiesPolicy : PersistentCookiesPolicy
This enumeration describes the policy of cookie persistency. If the profile is off-the-record, NoPersistentCookies is returned.
Access functions:
PersistentCookiesPolicy | persistentCookiesPolicy() const |
void | setPersistentCookiesPolicy(QQuickWebEngineProfile::PersistentCookiesPolicy) |
Notifier signal:
void | persistentCookiesPolicyChanged() |
persistentStoragePath : QString
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.
Access functions:
QString | persistentStoragePath() const |
void | setPersistentStoragePath(const QString &path) |
Notifier signal:
void | persistentStoragePathChanged() |
spellCheckEnabled : bool
This property holds whether the web engine spell checker is enabled.
This property was introduced in QtWebEngine 1.4.
Access functions:
bool | isSpellCheckEnabled() const |
void | setSpellCheckEnabled(bool enabled) |
Notifier signal:
void | spellCheckEnabledChanged() |
spellCheckLanguages : QStringList
This property holds the languages used by the spell checker.
This property was introduced in QtWebEngine 1.4.
Access functions:
QStringList | spellCheckLanguages() const |
void | setSpellCheckLanguages(const QStringList &languages) |
Notifier signal:
void | spellCheckLanguagesChanged() |
storageName : QString
The storage name that is used to create separate subdirectories for each profile that uses the disk for storing persistent data and cache.
Access functions:
QString | storageName() const |
void | setStorageName(const QString &name) |
Notifier signal:
void | storageNameChanged() |
See also QQuickWebEngineProfile::persistentStoragePath and QQuickWebEngineProfile::cachePath.
Member Function Documentation
QQuickWebEngineProfile::QQuickWebEngineProfile(QObject *parent = Q_NULLPTR)
Constructs a new profile with the parent parent.
void QQuickWebEngineProfile::clearHttpCache()
Removes the profile's cache entries.
This function was introduced in Qt 5.7.
See also WebEngineProfile::clearHttpCache.
QWebEngineCookieStore *QQuickWebEngineProfile::cookieStore() const
Returns the cookie store for this profile.
[static]
QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile()
Returns the default profile.
The default profile uses the storage name "Default".
See also storageName().
[signal]
void QQuickWebEngineProfile::downloadFinished(QQuickWebEngineDownloadItem *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.
[signal]
void QQuickWebEngineProfile::downloadRequested(QQuickWebEngineDownloadItem *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 QQuickWebEngineDownloadItem::accept()
or it will be cancelled by default. The download item is parented by the profile. If it is not accepted, it will be deleted immediately after the signal emission. This signal cannot be used with a queued connection.
void QQuickWebEngineProfile::installUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler)
Registers a handler handler for custom URL scheme scheme in the profile.
void QQuickWebEngineProfile::removeAllUrlSchemeHandlers()
Removes all custom URL scheme handlers installed in the profile.
void QQuickWebEngineProfile::removeUrlScheme(const QByteArray &scheme)
Removes the custom URL scheme scheme from the profile.
See also removeUrlSchemeHandler().
void QQuickWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
Removes the custom URL scheme handler handler from the profile.
See also removeUrlScheme().
void QQuickWebEngineProfile::setRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
Registers a request interceptor singleton interceptor to intercept URL requests.
The profile does not take ownership of the pointer.
See also QWebEngineUrlRequestInterceptor.
QStringList QQuickWebEngineProfile::spellCheckLanguages() const
Returns the list of languages used by the spell checker.
This function was introduced in Qt 5.8.
Note: Getter function for property spellCheckLanguages.
See also setSpellCheckLanguages().
const QWebEngineUrlSchemeHandler *QQuickWebEngineProfile::urlSchemeHandler(const QByteArray &scheme) const
Returns the custom URL scheme handler register for the URL scheme scheme.
© 2017 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.