WebEngineProfilePrototype QML Type

创建QQuickWebEngineProfile 类的实例。更多

Import Statement: import QtWebEngine
Since: QtWebEngine 6.9

属性

详细说明

WebEngineProfile 包含设置、脚本以及属于该配置文件的所有视图共享的访问链接列表。配置文件的某些属性必须在一次调用中初始化,并且在配置文件生命周期内不得修改。WebEngineProfilePrototype 提供了在设置了所有必要属性后创建配置文件的方法。

// creating OTR profile
WebEngineProfilePrototype: {
    id: otrProfile
}
let otrProfile = otrProfile.instance();

// creating non-OTR profile
WebEngineProfilePrototype: {
    id: nonOtrProfile
    storageName: 'Test'
}
let profile = nonOtrProfile.instance();

属性文档

cachePath : string

配置文件缓存(尤其是 HTTP 缓存)存储位置的路径。

默认情况下,缓存存储在QStandardPaths::writableLocation(QStandardPaths::CacheLocation) 下面的目录中,该目录使用storageName 命名。


httpCacheMaximumSize : int

HTTP 缓存的最大大小。如果0 ,大小将由QtWebEngine 自动控制。默认值为0

另请参阅 WebEngineProfilePrototype::httpCacheType


httpCacheType : enumeration

该枚举描述 HTTP 缓存的类型:

常量描述
WebEngineProfile.MemoryHttpCache使用内存缓存。如果设置了 offTheRecord 或没有可用的storageName (这是默认设置),这是唯一可能的设置。
WebEngineProfile.DiskHttpCache使用磁盘缓存。这是带有storageName 的非关记录配置文件的默认值。
WebEngineProfile.NoCache禁用缓存。

persistentCookiesPolicy : enumeration

该枚举描述了 cookie 持久性策略:

常量说明
WebEngineProfile.NoPersistentCookies会话和持久 cookie 都存储在内存中。如果设置了 offTheRecord 或没有storageName (这是默认设置),这是唯一可能的设置。
WebEngineProfile.AllowPersistentCookies标记为持久的 Cookie 会保存到磁盘并从磁盘恢复,而会话 Cookie 只会保存到磁盘以用于崩溃恢复。这是storageName 非关记录配置文件的默认值。
WebEngineProfile.ForcePersistentCookies会话和永久 cookie 都会保存到磁盘并从磁盘恢复。

persistentPermissionsPolicy : enumeration

该枚举描述了权限持久性策略:

常量说明
WebEngineProfile.AskEveryTime每次需要权限时,应用程序都会请求权限,无论之前是否已授予权限。这样做的目的是为了与现有应用程序向后兼容,否则不建议采用。
WebEngineProfile.StoreInMemory只有在第一次需要权限时才会提出请求。之后的任何请求都将根据用户最初的选择自动批准或拒绝。这将延续到使用同一QWebEngineProfile 实例的所有页面,直至应用程序关闭。如果设置了off-the-record 或没有可用的持久数据路径,则会应用此设置。
WebEngineProfile.StoreOnDisk工作方式与PersistentPermissionsInMemory 相同,但权限会保存到磁盘并从磁盘恢复。这是默认设置。

persistentStoragePath : string

浏览器和网页内容的持久数据存储位置路径。持久数据包括持久 cookie、HTML5 本地存储和访问过的链接。

默认情况下,存储位置位于QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) 下面,目录名为storageName


storageName : string

存储名称用于为使用磁盘存储持久数据和缓存的每个配置文件创建单独的子目录。存储名称必须是唯一的。

另请参阅 WebEngineProfilePrototype::persistentStoragePathWebEngineProfilePrototype::cachePath


© 2025 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.