Movatterモバイル変換


[0]ホーム

URL:


Back to Qt.io
Contact UsBlogDownload Qt
Qt documentation

QWebEngineProfile Class

The QWebEngineProfile class provides a web engine profile shared by multiple pages.More...

Header:#include <QWebEngineProfile>
qmake: QT += webenginewidgets
Since: Qt 5.5
Inherits:QObject

This class was introduced in Qt 5.5.

Public Types

enumHttpCacheType { MemoryHttpCache, DiskHttpCache, NoCache }
enumPersistentCookiesPolicy { NoPersistentCookies, AllowPersistentCookies, ForcePersistentCookies }

Public Functions

QWebEngineProfile(const QString &storageName, QObject *parent = Q_NULLPTR)
QWebEngineProfile(QObject *parent = Q_NULLPTR)
QStringcachePath() const
voidclearAllVisitedLinks()
voidclearHttpCache()
voidclearVisitedLinks(const QList<QUrl> &urls)
QWebEngineClientCertificateStore *clientCertificateStore()
QWebEngineCookieStore *cookieStore()
QStringdownloadPath() const
QStringhttpAcceptLanguage() const
inthttpCacheMaximumSize() const
QWebEngineProfile::HttpCacheTypehttpCacheType() const
QStringhttpUserAgent() const
voidinstallUrlSchemeHandler(const QByteArray &scheme, QWebEngineUrlSchemeHandler *handler)
boolisOffTheRecord() const
boolisSpellCheckEnabled() const
QWebEngineProfile::PersistentCookiesPolicypersistentCookiesPolicy() const
QStringpersistentStoragePath() const
voidremoveAllUrlSchemeHandlers()
voidremoveUrlScheme(const QByteArray &scheme)
voidremoveUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)
QWebEngineScriptCollection *scripts() const
voidsetCachePath(const QString &path)
voidsetDownloadPath(const QString &path)
voidsetHttpAcceptLanguage(const QString &httpAcceptLanguage)
voidsetHttpCacheMaximumSize(intmaxSize)
voidsetHttpCacheType(QWebEngineProfile::HttpCacheTypehttpCacheType)
voidsetHttpUserAgent(const QString &userAgent)
voidsetNotificationPresenter(std::function<void (std::unique_ptr<QWebEngineNotification>)>notificationPresenter)
voidsetPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicynewPersistentCookiesPolicy)
voidsetPersistentStoragePath(const QString &path)
voidsetSpellCheckEnabled(boolenable)
voidsetSpellCheckLanguages(const QStringList &languages)
voidsetUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)
QWebEngineSettings *settings() const
QStringListspellCheckLanguages() const
QStringstorageName() const
const QWebEngineUrlSchemeHandler *urlSchemeHandler(const QByteArray &scheme) const
boolvisitedLinksContainsUrl(const QUrl &url) const

Signals

voiddownloadRequested(QWebEngineDownloadItem *download)

Static Public Members

QWebEngineProfile *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 commonQWebEngineSettings 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 bystorageName(). 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 toin-memory oron-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 callingclearVisitedLinks() 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 dedicatedoff-the-record profile for aprivate 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 bydefaultProfile(). It is a built-in profile that all web pages not specifically created with another profile belong to.

Implementing theQWebEngineUrlRequestInterceptor interface and registering the interceptor on a profile bysetUrlRequestInterceptor() enables intercepting, blocking, and modifying URL requests (QWebEngineUrlRequestInfo) before they reach the networking stack of Chromium.

AQWebEngineUrlSchemeHandler can be registered for a profile byinstallUrlSchemeHandler() to add support for custom URL schemes. Requests for the scheme are then issued toQWebEngineUrlSchemeHandler::requestStarted() asQWebEngineUrlRequestJob objects.

Spellchecking HTML form fields can be enabled per profile by using thesetSpellCheckEnabled() method and the current languages used for spellchecking can be set by using thesetSpellCheckLanguages() method.

Member Type Documentation

enum QWebEngineProfile::HttpCacheType

This enum describes the HTTP cache type:

ConstantValueDescription
QWebEngineProfile::MemoryHttpCache0Use an in-memory cache. This is the default ifoff-the-record is set.
QWebEngineProfile::DiskHttpCache1Use a disk cache. This is the default if the profile is notoff-the-record. If set on anoff-the-record profile will instead setMemoryHttpCache.
QWebEngineProfile::NoCache2Disable both in-memory and disk caching. (Added in Qt 5.7)

enum QWebEngineProfile::PersistentCookiesPolicy

This enum describes policy for cookie persistency:

ConstantValueDescription
QWebEngineProfile::NoPersistentCookies0Both session and persistent cookies are stored in memory. This is the only setting possible ifoff-the-record is set or no persistent data path is available.
QWebEngineProfile::AllowPersistentCookies1Cookies 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::ForcePersistentCookies2Both session and persistent cookies are saved to and restored from disk.

Member Function Documentation

QWebEngineProfile::QWebEngineProfile(constQString &storageName,QObject *parent = Q_NULLPTR)

Constructs a new profile with the storage namestorageName and parentparent.

The storage name must be unique.

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.

See alsostorageName().

QWebEngineProfile::QWebEngineProfile(QObject *parent = Q_NULLPTR)

Constructs a new off-the-record profile with the parentparent.

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 alsoisOffTheRecord().

[signal]void QWebEngineProfile::downloadRequested(QWebEngineDownloadItem *download)

This signal is emitted whenever a download has been triggered. Thedownload argument holds the state of the download. The download has to be explicitly accepted withQWebEngineDownloadItem::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.

This function was introduced in Qt 5.5.

See alsoQWebEngineDownloadItem andQWebEnginePage::download().

QString QWebEngineProfile::cachePath() const

Returns the path used for caches.

By default, this is below StandardPaths::CacheLocation in a QtWebengine/StorageName specific subdirectory.

See alsosetCachePath(),storageName(), andQStandardPaths::writableLocation().

void QWebEngineProfile::clearAllVisitedLinks()

Clears all links from the visited links database.

See alsoclearVisitedLinks().

void QWebEngineProfile::clearHttpCache()

Removes the profile's cache entries.

This function was introduced in Qt 5.7.

void QWebEngineProfile::clearVisitedLinks(constQList<QUrl> &urls)

Clears the links inurls from the visited links database.

See alsoclearAllVisitedLinks().

QWebEngineClientCertificateStore *QWebEngineProfile::clientCertificateStore()

Returns the profile's client certificate store.

This function was introduced in Qt 5.13.

QWebEngineCookieStore *QWebEngineProfile::cookieStore()

Returns the cookie store for this profile.

This function was introduced in Qt 5.6.

[static]QWebEngineProfile *QWebEngineProfile::defaultProfile()

Returns the default profile.

The default profile uses the storage name "Default".

See alsostorageName().

QString QWebEngineProfile::downloadPath() const

The path to the location where the downloaded files are stored.

Note:By default, the download path isQStandardPaths::DownloadLocation.

This function was introduced in Qt 5.13.

See alsosetDownloadPath() andQStandardPaths::writableLocation().

QString QWebEngineProfile::httpAcceptLanguage() const

Returns the value of the Accept-Language HTTP request-header field.

This function was introduced in Qt 5.6.

See alsosetHttpAcceptLanguage().

int QWebEngineProfile::httpCacheMaximumSize() const

Returns the maximum size of the HTTP cache in bytes.

Will return0 if the size is automatically controlled byQtWebEngine.

See alsosetHttpCacheMaximumSize() andhttpCacheType().

QWebEngineProfile::HttpCacheType QWebEngineProfile::httpCacheType() const

Returns the type of HTTP cache used.

If the profile is off-the-record,MemoryHttpCache is returned.

See alsosetHttpCacheType() andcachePath().

QString QWebEngineProfile::httpUserAgent() const

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 alsosetHttpUserAgent().

void QWebEngineProfile::installUrlSchemeHandler(constQByteArray &scheme,QWebEngineUrlSchemeHandler *handler)

Registers a handlerhandler for custom URL schemescheme in the profile.

It is necessary to first register the scheme withQWebEngineUrlScheme::registerScheme at application startup.

This function was introduced in Qt 5.6.

bool QWebEngineProfile::isOffTheRecord() const

Returnstrue 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.

bool QWebEngineProfile::isSpellCheckEnabled() const

Returnstrue if the spell checker is enabled; otherwise returnsfalse.

This function was introduced in Qt 5.8.

See alsosetSpellCheckEnabled().

QWebEngineProfile::PersistentCookiesPolicy QWebEngineProfile::persistentCookiesPolicy() const

Returns the current policy for persistent cookies.

If the profile is off-the-record,NoPersistentCookies is returned.

See alsosetPersistentCookiesPolicy().

QString QWebEngineProfile::persistentStoragePath() const

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 belowQStandardPaths::DataLocation in a QtWebengine/StorageName specific subdirectory.

See alsosetPersistentStoragePath(),storageName(), andQStandardPaths::writableLocation().

void QWebEngineProfile::removeAllUrlSchemeHandlers()

Removes all custom URL scheme handlers installed in the profile.

This function was introduced in Qt 5.6.

void QWebEngineProfile::removeUrlScheme(constQByteArray &scheme)

Removes the custom URL schemescheme from the profile.

This function was introduced in Qt 5.6.

See alsoremoveUrlSchemeHandler().

void QWebEngineProfile::removeUrlSchemeHandler(QWebEngineUrlSchemeHandler *handler)

Removes the custom URL scheme handlerhandler from the profile.

This function was introduced in Qt 5.6.

See alsoremoveUrlScheme().

QWebEngineScriptCollection *QWebEngineProfile::scripts() const

Returns the collection of scripts that are injected into all pages that share this profile.

See alsoQWebEngineScriptCollection,QWebEngineScript,QWebEnginePage::scripts(), andScript Injection.

void QWebEngineProfile::setCachePath(constQString &path)

Overrides the default path used for disk caches, setting it topath.

If set to the null string, the default path is restored.

See alsocachePath().

void QWebEngineProfile::setDownloadPath(constQString &path)

Overrides the default path used for download location, setting it topath.

If set to the null string, the default path is restored.

This function was introduced in Qt 5.13.

See alsodownloadPath().

void QWebEngineProfile::setHttpAcceptLanguage(constQString &httpAcceptLanguage)

Sets the value of the Accept-Language HTTP request-header field tohttpAcceptLanguage.

This function was introduced in Qt 5.6.

See alsohttpAcceptLanguage().

void QWebEngineProfile::setHttpCacheMaximumSize(intmaxSize)

Sets the maximum size of the HTTP cache tomaxSize bytes.

Setting it to0 means the size will be controlled automatically byQtWebEngine.

See alsohttpCacheMaximumSize() andsetHttpCacheType().

void QWebEngineProfile::setHttpCacheType(QWebEngineProfile::HttpCacheTypehttpCacheType)

Sets the HTTP cache type tohttpCacheType.

See alsohttpCacheType() andsetCachePath().

void QWebEngineProfile::setHttpUserAgent(constQString &userAgent)

Overrides the default user-agent string, setting it touserAgent.

See alsohttpUserAgent().

void QWebEngineProfile::setNotificationPresenter(std::function<void (std::unique_ptr<QWebEngineNotification>)>notificationPresenter)

Sets the functionnotificationPresenter as responsible for presenting sent notifications.

This function was introduced in Qt 5.13.

See alsoQWebEngineNotification.

void QWebEngineProfile::setPersistentCookiesPolicy(QWebEngineProfile::PersistentCookiesPolicynewPersistentCookiesPolicy)

Sets the policy for persistent cookies tonewPersistentCookiesPolicy.

See alsopersistentCookiesPolicy().

void QWebEngineProfile::setPersistentStoragePath(constQString &path)

Overrides the default path used to store persistent web engine data.

Ifpath is set to the null string, the default path is restored.

See alsopersistentStoragePath().

void QWebEngineProfile::setSpellCheckEnabled(boolenable)

Enables spell checker ifenable istrue, otherwise disables it.

This function was introduced in Qt 5.8.

See alsoisSpellCheckEnabled().

void QWebEngineProfile::setSpellCheckLanguages(constQStringList &languages)

Sets the current list oflanguages 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 theSpellchecker feature documentation for how dictionary files are searched.

For more information about how to compile.bdic dictionaries, see theSpellchecker Example.

This function was introduced in Qt 5.8.

See alsospellCheckLanguages().

void QWebEngineProfile::setUrlRequestInterceptor(QWebEngineUrlRequestInterceptor *interceptor)

Registers a request interceptor singletoninterceptor to intercept URL requests.

The profile does not take ownership of the pointer.

This function was introduced in Qt 5.13.

See alsoQWebEngineUrlRequestInfo andQWebEngineUrlRequestInterceptor.

QWebEngineSettings *QWebEngineProfile::settings() const

Returns the default settings for all pages in this profile.

QStringList QWebEngineProfile::spellCheckLanguages() const

Returns the list of languages used by the spell checker.

This function was introduced in Qt 5.8.

See alsosetSpellCheckLanguages().

QString QWebEngineProfile::storageName() const

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.

constQWebEngineUrlSchemeHandler *QWebEngineProfile::urlSchemeHandler(constQByteArray &scheme) const

Returns the custom URL scheme handler register for the URL schemescheme.

This function was introduced in Qt 5.6.

bool QWebEngineProfile::visitedLinksContainsUrl(constQUrl &url) const

Returnstrue ifurl is considered a visited link by this profile.

© 2024 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 theGNU 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.

Contents

Qt Group includes The Qt Company Oy and its global subsidiaries and affiliates.


[8]ページ先頭

©2009-2025 Movatter.jp