本页内容

QWebViewSettings Class

允许配置浏览器的属性和特征。更多...

标题: #include <QWebViewSettings>
CMake: find_package(Qt6 REQUIRED COMPONENTS WebView)
target_link_libraries(mytarget PRIVATE Qt6::WebView)
qmake: QT += webview
自: Qt 6.11

公共类型

enum class WebAttribute { LocalStorageEnabled, JavaScriptEnabled, AllowFileAccess, LocalContentCanAccessFileUrls }

公共函数

void setAttribute(QWebViewSettings::WebAttribute attribute, bool on)
bool testAttribute(QWebViewSettings::WebAttribute attribute) const

详细说明

QWebViewSettings 对象可用于配置浏览器属性及通用属性,例如 JavaScript 支持、文件访问和本地存储功能。

默认值保留为各平台所设定的值。

成员类型文档

enum class QWebViewSettings::WebAttribute

此枚举类型用于指定网页的设置:

常量值描述
QWebViewSettings::WebAttribute::LocalStorageEnabled0启用对 HTML 5 本地存储功能的支持。
QWebViewSettings::WebAttribute::JavaScriptEnabled1启用 JavaScript 程序的运行。
QWebViewSettings::WebAttribute::AllowFileAccess2启用WebView 加载文件URL。
QWebViewSettings::WebAttribute::LocalContentCanAccessFileUrls3允许本地加载的文档访问其他本地 URL。

成员函数文档

void QWebViewSettings::setAttribute(QWebViewSettings::WebAttribute attribute, bool on)

根据on 的值,启用或禁用指定的attribute 功能。

bool QWebViewSettings::testAttribute(QWebViewSettings::WebAttribute attribute) const

如果启用了attribute ,则返回true ;否则返回false 。

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