QWebEngineProfileBuilder Class

The QWebEngineProfileBuilder class provides a way to construct QWebEngineProfile . 更多...

頭: #include <QWebEngineProfileBuilder>
CMake: find_package(Qt6 REQUIRED COMPONENTS WebEngineCore)
target_link_libraries(mytarget PRIVATE Qt6::WebEngineCore)
qmake: QT += webenginecore
Since: Qt 6.9

公共函數

QWebEngineProfile * createProfile (const QString & storageName , QObject * parent = nullptr) const
(從 6.10 起) QWebEngineProfileBuilder & setAdditionalTrustedCertificates (const QList<QSslCertificate> & certificates )
QWebEngineProfileBuilder & setCachePath (const QString & path )
QWebEngineProfileBuilder & setHttpCacheMaximumSize (int maxSizeInBytes )
QWebEngineProfileBuilder & setHttpCacheType (QWebEngineProfile::HttpCacheType httpCacheType )
QWebEngineProfileBuilder & setPersistentCookiesPolicy (QWebEngineProfile::PersistentCookiesPolicy persistentCookiePolicy )
QWebEngineProfileBuilder & setPersistentPermissionsPolicy (QWebEngineProfile::PersistentPermissionsPolicy persistentPermissionPolicy )
QWebEngineProfileBuilder & setPersistentStoragePath (const QString & path )

靜態公共成員

QWebEngineProfile * createOffTheRecordProfile (QObject * parent = nullptr)

詳細描述

A QWebEngineProfileBuilder 創建實例為 QWebEngineProfile class. Some profile's properties have to be initialized in one call and should not be modified during profile lifetime. The web engine profile builder simply guards that.

成員函數文檔編製

[static] QWebEngineProfile *QWebEngineProfileBuilder:: createOffTheRecordProfile ( QObject * parent = nullptr)

Creates an off-the-record profile with the parent object parent that leaves no record on the local machine and has no persistent data or cache. This will force cookies, persistent data and HTTP cache to be stored in memory

QWebEngineProfile *QWebEngineProfileBuilder:: createProfile (const QString & storageName , QObject * parent = nullptr) const

Constructs a profile with the storage name storageName 和父級 parent .

The storage name is used to give each disk-based profile, a separate subdirectory for persistent data and cache. The storage location must be unique during application life time. It is up to the user to prevent the creation of profiles with same storage's location, which can lead to corrupted browser cache.

A disk-based QWebEngineProfile should be destroyed before the application exit, otherwise the cache and persistent data may not be fully flushed to disk.

注意: When creating a disk-based profile, if the data path is already in use by another profile, the function will return a null pointer.

另請參閱 QWebEngineProfile::storageName ().

[since 6.10] QWebEngineProfileBuilder &QWebEngineProfileBuilder:: setAdditionalTrustedCertificates (const QList < QSslCertificate > & certificates )

Sets additional certificates for this profile's CA certificate database to certificates .

該函數在 Qt 6.10 引入。

QWebEngineProfileBuilder &QWebEngineProfileBuilder:: setCachePath (const QString & path )

Sets the path used for the cache to path .

默認情況下,這位於 QtWebengine/StorageName 特定子目錄中 StandardPaths::CacheLocation 下。

注意: 使用 QStandardPaths::writableLocation ( QStandardPaths::CacheLocation ) 以獲得 QStandardPaths::CacheLocation 路徑。

另請參閱 QWebEngineProfile::cachePath () 和 QStandardPaths::writableLocation ().

QWebEngineProfileBuilder &QWebEngineProfileBuilder:: setHttpCacheMaximumSize ( int maxSizeInBytes )

把 HTTP 緩存的最大尺寸設為 maxSizeInBytes 字節。

把它設為 0 意味著尺寸將被自動控製由 QtWebEngine .

另請參閱 QWebEngineProfile::httpCacheMaximumSize () 和 setHttpCacheType ().

QWebEngineProfileBuilder &QWebEngineProfileBuilder:: setHttpCacheType ( QWebEngineProfile::HttpCacheType httpCacheType )

把 HTTP 緩存類型設為 httpCacheType .

另請參閱 QWebEngineProfile::httpCacheType () 和 setCachePath ().

QWebEngineProfileBuilder &QWebEngineProfileBuilder:: setPersistentCookiesPolicy ( QWebEngineProfile::PersistentCookiesPolicy persistentCookiePolicy )

把持久 Cookie 策略設為 persistentCookiePolicy .

另請參閱 QWebEngineProfile::persistentCookiesPolicy ().

QWebEngineProfileBuilder &QWebEngineProfileBuilder:: setPersistentPermissionsPolicy ( QWebEngineProfile::PersistentPermissionsPolicy persistentPermissionPolicy )

Sets the policy for persistent permissions to persistentPermissionPolicy .

另請參閱 QWebEngineProfile::persistentPermissionsPolicy ().

QWebEngineProfileBuilder &QWebEngineProfileBuilder:: setPersistentStoragePath (const QString & path )

Sets the path used to store persistent data for the browser and web content to path . Persistent data includes persistent cookies, HTML5 local storage, and visited links.

By default, this is below QStandardPaths::DataLocation in a QtWebengine/StorageName specific subdirectory.

注意: 使用 QStandardPaths::writableLocation (QStandardPaths::DataLocation) to obtain the QStandardPaths::DataLocation path.

另請參閱 QWebEngineProfile::persistentStoragePath () 和 QStandardPaths::writableLocation ().