QWebEngineProfileclass provides a web engine profile shared by multiple pages. 更多 …
def
cachePath
()
def
clearAllVisitedLinks
()
def
clearHttpCache
()
def
clearVisitedLinks
(urls)
def
cookieStore
()
def
downloadPath
()
def
httpAcceptLanguage
()
def
httpCacheMaximumSize
()
def
httpCacheType
()
def
httpUserAgent
()
def
installUrlSchemeHandler
(scheme, arg__2)
def
isOffTheRecord
()
def
isSpellCheckEnabled
()
def
persistentCookiesPolicy
()
def
persistentStoragePath
()
def
removeAllUrlSchemeHandlers
()
def
removeUrlScheme
(scheme)
def
removeUrlSchemeHandler
(arg__1)
def
scripts
()
def
setCachePath
(path)
def
setDownloadPath
(path)
def
setHttpAcceptLanguage
(httpAcceptLanguage)
def
setHttpCacheMaximumSize
(maxSize)
def
setHttpCacheType
(arg__1)
def
setHttpUserAgent
(userAgent)
def
setPersistentCookiesPolicy
(arg__1)
def
setPersistentStoragePath
(path)
def
setRequestInterceptor
(interceptor)
def
setSpellCheckEnabled
(enabled)
def
setSpellCheckLanguages
(languages)
def
setUrlRequestInterceptor
(interceptor)
def
setUseForGlobalCertificateVerification
([enabled=true])
def
settings
()
def
spellCheckLanguages
()
def
storageName
()
def
urlSchemeHandler
(arg__1)
def
visitedLinksContainsUrl
(url)
def
downloadRequested
(download)
def
defaultProfile
()
Web 引擎配置文件包含设置、脚本、持久性 Cookie 策略及属于配置文件由所有 Web 引擎页面共享的拜访链接列表。
属于配置文件的所有页面共享公共
QWebEngineSettings实例,可以访问采用settings()method. Likewise, thescripts()method provides access to a commonQWebEngineScriptCollection实例。Information about visited links is stored together with persistent cookies and other persistent data in a storage returned by
storageName(). Persistent data is stored in a subdirectory set by callingsetPersistentStoragePath(), and the cache is located in a subdirectory set by callingsetCachePath(). The cache type can be set to in-memory or on-disk 通过调用setHttpCacheType(). If only the storage name is set, the subdirectories are created and named automatically. If you set any of the values manually, you should do it before creating any pages that belong to the profile.可以清零缓存链接通过调用
clearVisitedLinks()orclearAllVisitedLinks().PersistentCookiesPolicy描述是否把会话和持久 Cookie 保存到内存或磁盘并从中还原。Profiles can be used to isolate pages from each other. A typical use case is a dedicated off-the-record profile for a 隐私浏览 mode. Using
QWebEngineProfile()without defining a storage name constructs a new off-the-record profile that leaves no record on the local machine, and has no persistent data or cache. TheisOffTheRecord()method can be used to check 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.实现
QWebEngineUrlRequestInterceptorinterface and registering the interceptor on a profile bysetUrlRequestInterceptor()enables intercepting, blocking, and modifying URL requests (QWebEngineUrlRequestInfo) 在它们到达 Chromium 网络堆栈之前。A
QWebEngineUrlSchemeHandler可以被注册为配置文件通过installUrlSchemeHandler()to add support for custom URL schemes. Requests for the scheme are then issued torequestStarted()asQWebEngineUrlRequestJob对象。可以启用每个配置文件的拼写检查 HTML 表单字段通过使用
setSpellCheckEnabled()method and the current languages used for spellchecking can be set by using thesetSpellCheckLanguages()方法。
QWebEngineProfile
(
[
parent=Q_NULLPTR
]
)
¶
QWebEngineProfile(name[, parent=Q_NULLPTR])
- param parent
QObject- param name
unicode
构造新 off-the-record 配置文件采用父级
parent
.
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 can only be non-persistent. Trying to change these settings will have no effect.
另请参阅
构造新配置文件采用存储名称
storageName
和父级
parent
.
存储名称必须唯一。
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.
另请参阅
PySide2.QtWebEngineWidgets.QWebEngineProfile.
HttpCacheType
¶
此枚举描述 HTTP 缓存类型:
|
常量 |
描述 |
|---|---|
|
QWebEngineProfile.MemoryHttpCache |
使用内存中的缓存。这是默认设置若
|
|
QWebEngineProfile.DiskHttpCache |
使用磁盘缓存。这是默认设置若配置文件不为
|
|
QWebEngineProfile.NoCache |
禁用内存和磁盘缓存。(在 Qt 5.7 添加) |
PySide2.QtWebEngineWidgets.QWebEngineProfile.
PersistentCookiesPolicy
¶
此枚举描述 Cookie 持久性策略:
|
常量 |
描述 |
|---|---|
|
QWebEngineProfile.NoPersistentCookies |
Both session and persistent cookies are stored in memory. This is the only setting possible if
|
|
QWebEngineProfile.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. |
|
QWebEngineProfile.ForcePersistentCookies |
会话和持久 Cookie 均保存到磁盘并从中还原。 |
PySide2.QtWebEngineWidgets.QWebEngineProfile.
cachePath
(
)
¶
unicode
返回用于缓存的路径。
默认情况下,这位于 QtWebengine/StorageName 特定子目录中 StandardPaths::CacheLocation 下。
注意
使用
writableLocation
(
CacheLocation
) 以获得
CacheLocation
路径。
另请参阅
setCachePath()
storageName()
writableLocation()
PySide2.QtWebEngineWidgets.QWebEngineProfile.
clearAllVisitedLinks
(
)
¶
清零所有链接从拜访链接数据库。
另请参阅
PySide2.QtWebEngineWidgets.QWebEngineProfile.
clearHttpCache
(
)
¶
Removes the profile’s cache entries.
PySide2.QtWebEngineWidgets.QWebEngineProfile.
clearVisitedLinks
(
urls
)
¶
urls –
清零链接在
urls
从拜访链接数据库
QWebEngineCookieStore
返回此配置文件的 Cookie 存储。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
defaultProfile
(
)
¶
返回默认配置文件。
The default profile uses the storage name “Default”.
另请参阅
PySide2.QtWebEngineWidgets.QWebEngineProfile.
downloadPath
(
)
¶
unicode
下载文件存储位置的路径。
注意
默认情况下,下载路径为
DownloadLocation
.
另请参阅
setDownloadPath()
writableLocation()
PySide2.QtWebEngineWidgets.QWebEngineProfile.
downloadRequested
(
download
)
¶
download
–
QWebEngineDownloadItem
PySide2.QtWebEngineWidgets.QWebEngineProfile.
httpAcceptLanguage
(
)
¶
unicode
返回 Accept-Language HTTP 请求头字段的值。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
httpCacheMaximumSize
(
)
¶
int
返回 HTTP 缓存的最大尺寸,以字节为单位。
将返回
0
若尺寸被自动控制由
QtWebEngine
.
PySide2.QtWebEngineWidgets.QWebEngineProfile.
httpCacheType
(
)
¶
返回所用 HTTP 缓存类型。
若配置文件为 off-the-record,
MemoryHttpCache
被返回。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
httpUserAgent
(
)
¶
unicode
返回与 HTTP 一起发送,以标识浏览器的用户代理字符串。
注意
On Windows 8.1 and newer, the default user agent will always report “Windows NT 6.2” (Windows 8), unless the application does contain a manifest that declares newer Windows versions as supported.
另请参阅
PySide2.QtWebEngineWidgets.QWebEngineProfile.
installUrlSchemeHandler
(
scheme
,
arg__2
)
¶
scheme
–
QByteArray
arg__2
–
QWebEngineUrlSchemeHandler
注册处理程序
handler
为自定义 URL 方案
scheme
在配置文件中。
它是必要的,首先注册方案采用
registerScheme
在应用程序启动时。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
isOffTheRecord
(
)
¶
bool
返回
true
若这是 off-the-record 配置文件 (离开计算机无记录)。
这将强制 Cookie 和 HTTP 缓存在内存中,但也强制所有其它通常持久数据存储在内存中。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
isSpellCheckEnabled
(
)
¶
bool
返回
true
若拼写检查器被启用;否则返回
false
.
PySide2.QtWebEngineWidgets.QWebEngineProfile.
isUsedForGlobalCertificateVerification
(
)
¶
bool
返回
true
如果此配置文件目前被用于全局证书验证。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
persistentCookiesPolicy
(
)
¶
返回持久 Cookie 的当前策略。
若配置文件为 off-the-record,
NoPersistentCookies
被返回。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
persistentStoragePath
(
)
¶
unicode
返回用于存储浏览器和 Web 内容持久数据的路径。
持久数据包括:持久 Cookie、HTML5 本地存储、拜访链接。
默认情况下,这在
DataLocation
下在 QtWebengine/StorageName 特定子目录中。
注意
使用
writableLocation
(
DataLocation
) 以获得
DataLocation
路径。
另请参阅
setPersistentStoragePath()
storageName()
writableLocation()
PySide2.QtWebEngineWidgets.QWebEngineProfile.
removeAllUrlSchemeHandlers
(
)
¶
移除配置文件中安装的所有自定义 URL 方案处理程序。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
removeUrlScheme
(
scheme
)
¶
scheme
–
QByteArray
称除自定义 URL 方案
scheme
从配置文件。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
removeUrlSchemeHandler
(
arg__1
)
¶
arg__1
–
QWebEngineUrlSchemeHandler
移除自定义 URL 方案处理程序
handler
从配置文件。
另请参阅
PySide2.QtWebEngineWidgets.QWebEngineProfile.
scripts
(
)
¶
QWebEngineScriptCollection
返回注入到共享此配置文件的所有页面中的脚本集合。
另请参阅
QWebEngineScriptCollection
QWebEngineScript
scripts()
脚本注入
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setCachePath
(
path
)
¶
path – unicode
覆盖用于磁盘缓存的默认路径,将其设为
path
.
若设为 null 字符串,则还原默认路径。
另请参阅
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setDownloadPath
(
path
)
¶
path – unicode
覆盖用于下载位置的默认路径,将其设为
path
.
若设为 null 字符串,则还原默认路径。
另请参阅
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setHttpAcceptLanguage
(
httpAcceptLanguage
)
¶
httpAcceptLanguage – unicode
把 Accept-Language HTTP 请求头字段值设为
httpAcceptLanguage
.
另请参阅
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setHttpCacheMaximumSize
(
maxSize
)
¶
maxSize
–
int
把 HTTP 缓存的最大尺寸设为
maxSize
字节。
把它设为
0
意味着尺寸将被自动控制由
QtWebEngine
.
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setHttpCacheType
(
arg__1
)
¶
arg__1
–
HttpCacheType
把 HTTP 缓存类型设为
httpCacheType
.
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setHttpUserAgent
(
userAgent
)
¶
userAgent – unicode
覆盖默认用户代理字符串,将其设为
userAgent
.
另请参阅
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setPersistentCookiesPolicy
(
arg__1
)
¶
arg__1
–
PersistentCookiesPolicy
把持久 Cookie 策略设为
newPersistentCookiesPolicy
.
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setPersistentStoragePath
(
path
)
¶
path – unicode
覆盖用于存储持久 Web 引擎数据的默认路径。
若
path
设为 null 字符串,则还原默认路径。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setRequestInterceptor
(
interceptor
)
¶
interceptor
–
QWebEngineUrlRequestInterceptor
注册请求拦截器单例
interceptor
到拦截 URL 请求。
配置文件不拥有指针的所有权。
Interceptors installed with this method will call
interceptRequest
on the I/O thread. Therefore the user has to provide thread-safe interaction with the other user classes. For a duration of this call ui thread is blocked. Use
setUrlRequestInterceptor
代替。
另请参阅
QWebEngineUrlRequestInfo
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setSpellCheckEnabled
(
enabled
)
¶
enabled
–
bool
启用拼写检查器,若
enable
is
true
,否则禁用它。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setSpellCheckLanguages
(
languages
)
¶
languages – 字符串列表
设置当前列表
languages
为拼写检查器。每种语言应该匹配的名称源于
.bdic
字典。例如,语言
en-US
将加载
en-US.bdic
字典文件。
见 拼写检查器特征文档编制 如何搜索字典文件。
了解更多信息关于如何编译
.bdic
字典,见
拼写检查器范例
.
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setUrlRequestInterceptor
(
interceptor
)
¶
interceptor
–
QWebEngineUrlRequestInterceptor
注册请求拦截器单例
interceptor
到拦截 URL 请求。
配置文件不拥有指针的所有权。
另请参阅
QWebEngineUrlRequestInfo
QWebEngineUrlRequestInterceptor
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setUseForGlobalCertificateVerification
(
[
enabled=true
]
)
¶
enabled
–
bool
Sets if this profile is to be used for downloading and caching when needed during certificate verification, for instance for OCSP, CRLs, and AIA.
Only one
QWebEngineProfile
can do this at a time, and it is recommended that the profile fullfilling this role has a disk HTTP cache to avoid needlessly re-downloading. If you set the option on a second profile, it will be disabled on the profile it is currently set.
目前,仅影响启用 OCSP 的 Linux/NSS 安装。
只要一个配置文件已
enabled
设为
true
,所有其它配置文件都将能够使用它进行证书验证。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
settings
(
)
¶
QWebEngineSettings
返回在此配置文件中,所有页面的默认设置。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
spellCheckLanguages
(
)
¶
字符串列表
返回拼写检查器所用的语言列表。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
storageName
(
)
¶
unicode
返回配置文件的存储名称。
存储名称为每个配置文件 (对于持久数据和缓存) 提供使用磁盘的单独子目录。
PySide2.QtWebEngineWidgets.QWebEngineProfile.
urlSchemeHandler
(
arg__1
)
¶
arg__1
–
QByteArray
QWebEngineUrlSchemeHandler
返回自定义 URL 方案的处理程序寄存器,对于 URL 方案
scheme
.
PySide2.QtWebEngineWidgets.QWebEngineProfile.
visitedLinksContainsUrl
(
url
)
¶
url
–
QUrl
bool
返回
true
if
url
被认为通过此配置文件拜访过链接。