QWebEngineProfile¶
The
QWebEngineProfile
class provides a web engine profile shared by multiple pages. More…
Synopsis¶
Functions¶
def
cachePath
()def
clearAllVisitedLinks
()def
clearHttpCache
()def
clearVisitedLinks
(urls)def
cookieStore
()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
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
settings
()def
spellCheckLanguages
()def
storageName
()def
urlSchemeHandler
(arg__1)def
visitedLinksContainsUrl
(url)
Signals¶
def
downloadRequested
(download)
Static functions¶
def
defaultProfile
()
Detailed Description¶
A web engine profile contains settings, scripts, persistent cookie policy, and the list of visited links shared by all web engine pages that belong to the profile.
All pages that belong to the profile share a common
QWebEngineSettings
instance, which can be accessed with thesettings()
method. Likewise, thescripts()
method provides access to a commonQWebEngineScriptCollection
instance.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 by callingsetHttpCacheType()
. 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.The cache can be cleared of links by calling
clearVisitedLinks()
orclearAllVisitedLinks()
.PersistentCookiesPolicy
describes whether session and persistent cookies are saved to and restored from memory or disk.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. 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.Implementing the
QWebEngineUrlRequestInterceptor
interface and registering the interceptor on a profile bysetRequestInterceptor()
enables intercepting, blocking, and modifying URL requests (QWebEngineUrlRequestInfo
) before they reach the networking stack of Chromium.A
QWebEngineUrlSchemeHandler
can be registered for a profile byinstallUrlSchemeHandler()
to add support for custom URL schemes. Requests for the scheme are then issued torequestStarted()
asQWebEngineUrlRequestJob
objects.Spellchecking HTML form fields can be enabled per profile by using the
setSpellCheckEnabled()
method and the current languages used for spellchecking can be set by using thesetSpellCheckLanguages()
method.
-
class
QWebEngineProfile
([parent=Q_NULLPTR])¶ QWebEngineProfile(name[, parent=Q_NULLPTR])
- param parent
QObject
- param name
unicode
Constructs a new off-the-record profile with the parent
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.
See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
HttpCacheType
¶ This enum describes the HTTP cache type:
Constant
Description
QWebEngineProfile.MemoryHttpCache
Use an in-memory cache. This is the default if
off-the-record
is set.QWebEngineProfile.DiskHttpCache
Use a disk cache. This is the default if the profile is not
off-the-record
. If set on anoff-the-record
profile will instead setMemoryHttpCache
.QWebEngineProfile.NoCache
Disable both in-memory and disk caching. (Added in Qt 5.7)
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
PersistentCookiesPolicy
¶ This enum describes policy for cookie persistency:
Constant
Description
QWebEngineProfile.NoPersistentCookies
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.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
Both session and persistent cookies are saved to and restored from disk.
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
cachePath
()¶ - Return type
unicode
Returns the path used for caches.
By default, this is below StandardPaths::CacheLocation in a QtWebengine/StorageName specific subdirectory.
Note
Use
writableLocation
(CacheLocation
) to obtain theCacheLocation
path.See also
setCachePath()
storageName()
writableLocation()
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
clearAllVisitedLinks
()¶ Clears all links from the visited links database.
See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
clearHttpCache
()¶ Removes the profile’s cache entries.
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
clearVisitedLinks
(urls)¶ - Parameters
urls –
Clears the links in
urls
from the visited links database.See also
- Return type
QWebEngineCookieStore
Returns the cookie store for this profile.
-
static
PySide2.QtWebEngineWidgets.QWebEngineProfile.
defaultProfile
()¶ - Return type
Returns the default profile.
The default profile uses the storage name “Default”.
See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
downloadRequested
(download)¶ - Parameters
download –
QWebEngineDownloadItem
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
httpAcceptLanguage
()¶ - Return type
unicode
Returns the value of the Accept-Language HTTP request-header field.
See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
httpCacheMaximumSize
()¶ - Return type
int
Returns the maximum size of the HTTP cache in bytes.
Will return
0
if the size is automatically controlled by QtWebEngine .See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
httpCacheType
()¶ - Return type
Returns the type of HTTP cache used.
If the profile is off-the-record,
MemoryHttpCache
is returned.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
httpUserAgent
()¶ - Return type
unicode
Returns the user-agent string sent with HTTP to identify the browser.
Note
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.
See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
installUrlSchemeHandler
(scheme, arg__2)¶ - Parameters
scheme –
QByteArray
arg__2 –
QWebEngineUrlSchemeHandler
Registers a handler
handler
for custom URL schemescheme
in the profile.It is necessary to first register the scheme with
registerScheme
at application startup.
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
isOffTheRecord
()¶ - Return type
bool
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.
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
isSpellCheckEnabled
()¶ - Return type
bool
Returns
true
if the spell checker is enabled; otherwise returnsfalse
.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
persistentCookiesPolicy
()¶ - Return type
Returns the current policy for persistent cookies.
If the profile is off-the-record,
NoPersistentCookies
is returned.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
persistentStoragePath
()¶ - Return type
unicode
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
DataLocation
in a QtWebengine/StorageName specific subdirectory.Note
Use
writableLocation
(DataLocation
) to obtain theDataLocation
path.See also
setPersistentStoragePath()
storageName()
writableLocation()
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
removeAllUrlSchemeHandlers
()¶ Removes all custom URL scheme handlers installed in the profile.
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
removeUrlScheme
(scheme)¶ - Parameters
scheme –
QByteArray
Removes the custom URL scheme
scheme
from the profile.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
removeUrlSchemeHandler
(arg__1)¶ - Parameters
arg__1 –
QWebEngineUrlSchemeHandler
Removes the custom URL scheme handler
handler
from the profile.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
scripts
()¶ - Return type
QWebEngineScriptCollection
Returns the collection of scripts that are injected into all pages that share this profile.
See also
QWebEngineScriptCollection
QWebEngineScript
scripts()
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setCachePath
(path)¶ - Parameters
path – unicode
Overrides the default path used for disk caches, setting it to
path
.If set to the null string, the default path is restored.
See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setHttpAcceptLanguage
(httpAcceptLanguage)¶ - Parameters
httpAcceptLanguage – unicode
Sets the value of the Accept-Language HTTP request-header field to
httpAcceptLanguage
.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setHttpCacheMaximumSize
(maxSize)¶ - Parameters
maxSize –
int
Sets the maximum size of the HTTP cache to
maxSize
bytes.Setting it to
0
means the size will be controlled automatically by QtWebEngine .See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setHttpCacheType
(arg__1)¶ - Parameters
arg__1 –
HttpCacheType
Sets the HTTP cache type to
httpCacheType
.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setHttpUserAgent
(userAgent)¶ - Parameters
userAgent – unicode
Overrides the default user-agent string, setting it to
userAgent
.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setPersistentCookiesPolicy
(arg__1)¶ - Parameters
arg__1 –
PersistentCookiesPolicy
Sets the policy for persistent cookies to
newPersistentCookiesPolicy
.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setPersistentStoragePath
(path)¶ - Parameters
path – unicode
Overrides the default path used to store persistent web engine data.
If
path
is set to the null string, the default path is restored.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setRequestInterceptor
(interceptor)¶ - Parameters
interceptor –
QWebEngineUrlRequestInterceptor
Registers a request interceptor singleton
interceptor
to intercept URL requests.The profile does not take ownership of the pointer.
See also
QWebEngineUrlRequestInfo
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setSpellCheckEnabled
(enabled)¶ - Parameters
enabled –
bool
Enables spell checker if
enable
istrue
, otherwise disables it.See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
setSpellCheckLanguages
(languages)¶ - Parameters
languages – list of strings
Sets the current list of
languages
for the spell checker. Each language should match the name of the.bdic
dictionary. For example, the languageen-US
will load theen-US.bdic
dictionary file.See the Spellchecker feature documentation for how dictionary files are searched.
For more information about how to compile
.bdic
dictionaries, see the Spellchecker Example .See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
settings
()¶ - Return type
QWebEngineSettings
Returns the default settings for all pages in this profile.
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
spellCheckLanguages
()¶ - Return type
list of strings
Returns the list of languages used by the spell checker.
See also
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
storageName
()¶ - Return type
unicode
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.
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
urlSchemeHandler
(arg__1)¶ - Parameters
arg__1 –
QByteArray
- Return type
QWebEngineUrlSchemeHandler
Returns the custom URL scheme handler register for the URL scheme
scheme
.
-
PySide2.QtWebEngineWidgets.QWebEngineProfile.
visitedLinksContainsUrl
(url)¶ - Parameters
url –
QUrl
- Return type
bool
Returns
true
ifurl
is considered a visited link by this profile.
© 2018 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.