The QQuickWebEngineProfile class provides a web engine profile shared by multiple pages. 更多...
头: | #include <QQuickWebEngineProfile> |
Since: | Qt 5.6 |
实例化: | WebEngineProfile |
继承: | QObject |
该类在 Qt 5.6 引入。
enum | HttpCacheType { MemoryHttpCache, DiskHttpCache, NoCache } |
enum | PersistentCookiesPolicy { NoPersistentCookies, AllowPersistentCookies, ForcePersistentCookies } |
|
|
QQuickWebEngineProfile (QObject * parent = Q_NULLPTR) | |
QString | cachePath () const |
void | clearHttpCache () |
QWebEngineClientCertificateStore * | clientCertificateStore () |
QWebEngineCookieStore * | cookieStore () const |
QString | downloadPath () const |
QString | httpAcceptLanguage () const |
int | httpCacheMaximumSize () const |
QQuickWebEngineProfile::HttpCacheType | httpCacheType () const |
QString | httpUserAgent () const |
void | installUrlSchemeHandler (const QByteArray & scheme , QWebEngineUrlSchemeHandler * handler ) |
bool | isOffTheRecord () const |
bool | isSpellCheckEnabled () const |
QQuickWebEngineProfile::PersistentCookiesPolicy | persistentCookiesPolicy () const |
QString | persistentStoragePath () const |
void | removeAllUrlSchemeHandlers () |
void | removeUrlScheme (const QByteArray & scheme ) |
void | removeUrlSchemeHandler (QWebEngineUrlSchemeHandler * handler ) |
void | setCachePath (const QString & path ) |
void | setDownloadPath (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 | setSpellCheckEnabled (bool enabled ) |
void | setSpellCheckLanguages (const QStringList & languages ) |
void | setStorageName (const QString & name ) |
void | setUrlRequestInterceptor (QWebEngineUrlRequestInterceptor * interceptor ) |
QStringList | spellCheckLanguages () const |
QString | storageName () const |
const QWebEngineUrlSchemeHandler * | urlSchemeHandler (const QByteArray & scheme ) const |
QQmlListProperty<QQuickWebEngineScript> | userScripts () |
void | cachePathChanged () |
void | downloadFinished (QQuickWebEngineDownloadItem * download ) |
void | downloadPathChanged () |
void | downloadRequested (QQuickWebEngineDownloadItem * download ) |
void | httpAcceptLanguageChanged () |
void | httpCacheMaximumSizeChanged () |
void | httpCacheTypeChanged () |
void | httpUserAgentChanged () |
void | offTheRecordChanged () |
void | persistentCookiesPolicyChanged () |
void | persistentStoragePathChanged () |
void | presentNotification (QWebEngineNotification * notification ) |
void | spellCheckEnabledChanged () |
void | spellCheckLanguagesChanged () |
void | storageNameChanged () |
QQuickWebEngineProfile * | defaultProfile () |
Web 引擎 Profile (配置文件) 包含设置、脚本、持久性 Cookie 策略及属于 Profile 由所有 Web 引擎页面共享的拜访链接列表。
Information about visited links is stored together with persistent cookies and other persistent data in a storage determined by the storageName property. Persistent data is stored in a subdirectory determined by the persistentStoragePath property and the cache in a subdirectory determined by the cachePath property. The httpCacheType property describes the type of the cache: in-memory or on-disk . If only the storageName property is set, the other values are generated automatically based on it. If you specify any of the values manually, you should do it before creating any pages that belong to the profile.
Profiles can be used to isolate pages from each other. A typical use case is a dedicated off-the-record profile 对于 隐私浏览 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 特性。
此枚举描述 HTTP 缓存类型:
常量 | 值 | 描述 |
---|---|---|
QQuickWebEngineProfile::MemoryHttpCache
|
0
|
使用内存中的缓存。这是默认设置若
off-the-record
有设置。
|
QQuickWebEngineProfile::DiskHttpCache
|
1
|
Use a disk cache. This is the default if
off-the-record
is not set. Falls back to
MemoryHttpCache
if
off-the-record
有设置。
|
QQuickWebEngineProfile::NoCache
|
2
|
禁用内存和磁盘缓存。(在 Qt 5.7 添加) |
此枚举描述 Cookie 持久性策略:
常量 | 值 | 描述 |
---|---|---|
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
|
会话和持久 Cookie 均保存到磁盘并从中还原。 |
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 .
访问函数:
QString | cachePath () const |
void | setCachePath (const QString & path ) |
通知程序信号:
void | cachePathChanged () |
下载文件存储位置的路径。
覆盖用于下载位置的默认路径,将其设为 path .
If set to an empty string, the default path is restored.
注意: 默认情况下,下载路径为 QStandardPaths::DownloadLocation .
This property was introduced in QtWebEngine 1.9.
访问函数:
QString | downloadPath () const |
void | setDownloadPath (const QString & path ) |
通知程序信号:
void | downloadPathChanged () |
The value of the Accept-Language HTTP request-header field.
访问函数:
QString | httpAcceptLanguage () const |
void | setHttpAcceptLanguage (const QString & httpAcceptLanguage ) |
通知程序信号:
void | httpAcceptLanguageChanged () |
The maximum size of the HTTP cache. If
0
, the size will be controlled automatically by
QtWebEngine
。默认值为
0
.
访问函数:
int | httpCacheMaximumSize () const |
void | setHttpCacheMaximumSize (int maxSize ) |
通知程序信号:
void | httpCacheMaximumSizeChanged () |
另请参阅 httpCacheType .
This enumeration describes the type of the HTTP cache.
若 Profile (配置文件) 为 off-the-record, MemoryHttpCache 被返回。
访问函数:
QQuickWebEngineProfile::HttpCacheType | httpCacheType () const |
void | setHttpCacheType ( QQuickWebEngineProfile::HttpCacheType ) |
通知程序信号:
void | httpCacheTypeChanged () |
The user-agent string sent with HTTP to identify the browser.
访问函数:
QString | httpUserAgent () const |
void | setHttpUserAgent (const QString & userAgent ) |
通知程序信号:
void | httpUserAgentChanged () |
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.
访问函数:
bool | isOffTheRecord () const |
void | setOffTheRecord (bool offTheRecord ) |
通知程序信号:
void | offTheRecordChanged () |
This enumeration describes the policy of cookie persistency. If the profile is off-the-record, NoPersistentCookies 被返回。
访问函数:
QQuickWebEngineProfile::PersistentCookiesPolicy | persistentCookiesPolicy () const |
void | setPersistentCookiesPolicy ( QQuickWebEngineProfile::PersistentCookiesPolicy ) |
通知程序信号:
void | persistentCookiesPolicyChanged () |
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 .
访问函数:
QString | persistentStoragePath () const |
void | setPersistentStoragePath (const QString & path ) |
通知程序信号:
void | persistentStoragePathChanged () |
This property holds whether the web engine spell checker is enabled.
This property was introduced in QtWebEngine 1.4.
访问函数:
bool | isSpellCheckEnabled () const |
void | setSpellCheckEnabled (bool enabled ) |
通知程序信号:
void | spellCheckEnabledChanged () |
This property holds the languages used by the spell checker.
This property was introduced in QtWebEngine 1.4.
访问函数:
QStringList | spellCheckLanguages () const |
void | setSpellCheckLanguages (const QStringList & languages ) |
通知程序信号:
void | spellCheckLanguagesChanged () |
The storage name that is used to create separate subdirectories for each profile that uses the disk for storing persistent data and cache.
访问函数:
QString | storageName () const |
void | setStorageName (const QString & name ) |
通知程序信号:
void | storageNameChanged () |
另请参阅 persistentStoragePath and cachePath .
This property holds the collection of scripts that are injected into all pages that share this profile.
该特性在 Qt 5.9 引入。
访问函数:
QQmlListProperty<QQuickWebEngineScript> | userScripts () |
另请参阅 QQuickWebEngineScript and QQmlListReference .
Constructs a new profile with the parent parent .
[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
)
此信号被发射每当下载已被触发。
download
自变量保持下载的状态。下载必须被明确接受采用
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.
[signal]
void
QQuickWebEngineProfile::
presentNotification
(
QWebEngineNotification
*
notification
)
This signal is emitted whenever there is a newly created user notification. The notification argument holds the QWebEngineNotification instance to query data and interact with.
另请参阅 WebEngineProfile::presentNotification .
移除 Profile 的缓存条目。
注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .
该函数在 Qt 5.7 引入。
另请参阅 WebEngineProfile::clearHttpCache .
返回 Profile (配置文件) 的客户端证书存储。
该函数在 Qt 5.13 引入。
返回用于此 Profile (配置文件) 的 Cookie 存储。
[static]
QQuickWebEngineProfile
*QQuickWebEngineProfile::
defaultProfile
()
返回默认 Profile (配置文件)。
默认 Profile (配置文件) 使用 Default 存储名称。
另请参阅 storageName ().
注册处理程序 handler 为自定义 URL 方案 scheme 在 Profile (配置文件) 中。
它是必要的,首先注册方案采用 QWebEngineUrlScheme::registerScheme 在应用程序启动时。
移除 Profile (配置文件) 中安装的所有自定义 URL 方案处理程序。
称除自定义 URL 方案 scheme 从 Profile (配置文件)。
另请参阅 removeUrlSchemeHandler ().
移除自定义 URL 方案处理程序 handler 从 Profile (配置文件)。
另请参阅 removeUrlScheme ().
注册请求拦截器单例 interceptor 到拦截 URL 请求。
Profile (配置文件) 不拥有指针的所有权。
另请参阅 QWebEngineUrlRequestInfo and QWebEngineUrlRequestInterceptor .
返回拼写检查器所用的语言列表。
注意: Getter function for property spellCheckLanguages.
该函数在 Qt 5.8 引入。
另请参阅 setSpellCheckLanguages ().
返回自定义 URL 方案的处理程序寄存器,对于 URL 方案 scheme .