在本页

QWebViewSettings Class

允许配置浏览器属性和属性。更多

Header: #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允许本地加载的文档访问其他本地 URL。
QWebViewSettings::WebAttribute::LocalContentCanAccessFileUrls3允许WebView 加载文件 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.