QWebViewSettings Class

Allows configuration of browser properties and attributes. More...

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

Public Types

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

Public Functions

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

Detailed Description

The QWebViewSettings object can be used to configure browser properties and generic attributes, such as JavaScript support, file access and local storage features.

The default values are left as set by the different platforms.

Member Type Documentation

enum class QWebViewSettings::WebAttribute

This enum type specifies settings for web pages:

ConstantValueDescription
QWebViewSettings::WebAttribute::LocalStorageEnabled0Enables support for the HTML 5 local storage feature.
QWebViewSettings::WebAttribute::JavaScriptEnabled1Enables the running of JavaScript programs.
QWebViewSettings::WebAttribute::AllowFileAccess2Allows locally loaded documents to access other local URLs.
QWebViewSettings::WebAttribute::LocalContentCanAccessFileUrls3Enables the WebView to load file URLs.

Member Function Documentation

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

Enables or disables the specified attribute feature depending on the value of on.

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

Returns true if attribute is enabled; otherwise returns false.