QWebEngineProfile — PyQt Documentation v5.15.7 (original) (raw)
PyQt5.QtWebEngineWidgets.QWebEngineProfile
Inherits from QObject.
Description¶
The QWebEngineProfile class provides a web engine profile shared by multiple pages.
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 the settings() method. Likewise, the scripts() method provides access to a common QWebEngineScriptCollection 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 calling setPersistentStoragePath(), and the cache is located in a subdirectory set by calling setCachePath(). The cache type can be set to in-memory or on-disk by calling 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.
The cache can be cleared of links by calling clearVisitedLinks() or clearAllVisitedLinks(). 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. The isOffTheRecord() 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 by setRequestInterceptor() enables intercepting, blocking, and modifying URL requests (QWebEngineUrlRequestInfo) before they reach the networking stack of Chromium.
A QWebEngineUrlSchemeHandler can be registered for a profile by installUrlSchemeHandler() to add support for custom URL schemes. Requests for the scheme are then issued to QWebEngineUrlSchemeHandler::requestStarted() as QWebEngineUrlRequestJob 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 the setSpellCheckLanguages() method.
Enums¶
HttpCacheType
This enum describes the HTTP cache type:
Member | Value | Description |
---|---|---|
DiskHttpCache | 1 | Use a disk cache. This is the default if the profile is not off-the-record. If set on an off-the-record profile will instead set MemoryHttpCache. |
MemoryHttpCache | 0 | Use an in-memory cache. This is the default if off-the-record is set. |
NoCache | 2 | Disable both in-memory and disk caching. (Added in Qt 5.7) |
PersistentCookiesPolicy
TODO
Member | Value | Description |
---|---|---|
AllowPersistentCookies | TODO | TODO |
ForcePersistentCookies | TODO | TODO |
NoPersistentCookies | TODO | TODO |
Methods¶
__init__(parent: QObject = None)
TODO
__init__(str, parent: QObject = None)
TODO
cachePath() → str
clearAllVisitedLinks()
TODO
clearHttpCache()
TODO
clearVisitedLinks(Iterable[QUrl])
TODO
clientCertificateStore() → QWebEngineClientCertificateStore
TODO
cookieStore() → QWebEngineCookieStore
TODO
@staticmethod
defaultProfile() → QWebEngineProfile
TODO
downloadPath() → str
TODO
httpAcceptLanguage() → str
httpCacheMaximumSize() → int
httpCacheType() → HttpCacheType
See also
httpUserAgent() → str
See also
installUrlSchemeHandler(Union[QByteArray, bytes, bytearray], QWebEngineUrlSchemeHandler)
TODO
isOffTheRecord() → bool
TODO
isSpellCheckEnabled() → bool
TODO
isUsedForGlobalCertificateVerification() → bool
TODO
persistentCookiesPolicy() → PersistentCookiesPolicy
persistentStoragePath() → str
removeAllUrlSchemeHandlers()
TODO
removeUrlScheme(Union[QByteArray, bytes, bytearray])
TODO
removeUrlSchemeHandler(QWebEngineUrlSchemeHandler)
TODO
scripts() → QWebEngineScriptCollection
TODO
setCachePath(str)
setDownloadPath(str)
TODO
setHttpAcceptLanguage(str)
See also
setHttpCacheMaximumSize(int)
setHttpCacheType(HttpCacheType)
See also
setHttpUserAgent(str)
See also
setNotificationPresenter(Callable[[QWebEngineNotification], None])
TODO
setPersistentCookiesPolicy(PersistentCookiesPolicy)
TODO
setPersistentStoragePath(str)
setRequestInterceptor(QWebEngineUrlRequestInterceptor)
TODO
setSpellCheckEnabled(bool)
setSpellCheckLanguages(Iterable[str])
settings() → QWebEngineSettings
TODO
setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor)
TODO
setUseForGlobalCertificateVerification(enabled: bool = True)
TODO
spellCheckLanguages() → List[str]
storageName() → str
TODO
urlSchemeHandler(Union[QByteArray, bytes, bytearray]) → QWebEngineUrlSchemeHandler
TODO
visitedLinksContainsUrl(QUrl) → bool
TODO
Signals¶
downloadRequested(QWebEngineDownloadItem)
TODO