Qt 5.11 | Qt WebEngine | C++ Classes | QWebEngineSettings

Qt 5.11.3 Reference Documentation

# QWebEngineSettings Class

The QWebEngineSettings class provides an object to store the settings used by QWebEnginePage. More...

Header: | #include <QWebEngineSettings>
qmake: | QT += webenginewidgets
Since: | Qt 5.4

- List of all members, including inherited members

## Public Types

enum | FontFamily { StandardFont, FixedFont, SerifFont, SansSerifFont, ..., PictographFont }
enum | FontSize { MinimumFontSize, MinimumLogicalFontSize, DefaultFontSize, DefaultFixedFontSize }
enum | UnknownUrlSchemePolicy { DisallowUnknownUrlSchemes, AllowUnknownUrlSchemesFromUserInteraction, AllowAllUnknownUrlSchemes }
enum | WebAttribute { AutoLoadImages, JavascriptEnabled, JavascriptCanOpenWindows, JavascriptCanAccessClipboard, ..., WebRTCPublicInterfacesOnly }

## Public Functions

QString | defaultTextEncoding() const
QString | fontFamily(QWebEngineSettings::FontFamily which) const
int | fontSize(QWebEngineSettings::FontSize type) const
void | resetAttribute(QWebEngineSettings::WebAttribute attr)
void | resetFontFamily(QWebEngineSettings::FontFamily which)
void | resetFontSize(QWebEngineSettings::FontSize type)
void | resetUnknownUrlSchemePolicy()
void | setAttribute(QWebEngineSettings::WebAttribute attr, bool on)
void | setDefaultTextEncoding(const QString &encoding)
void | setFontFamily(QWebEngineSettings::FontFamily which, const QString &family)
void | setFontSize(QWebEngineSettings::FontSize type, int size)
void | setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy)
bool | testAttribute(QWebEngineSettings::WebAttribute attr) const
QWebEngineSettings::UnknownUrlSchemePolicy | unknownUrlSchemePolicy() const

## Static Public Members

QWebEngineSettings * | defaultSettings()
QWebEngineSettings * | globalSettings()

## Detailed Description

The QWebEngineSettings class provides an object to store the settings used by QWebEnginePage.

QWebEngineSettings allows configuration of browser properties, such as font sizes and families, the location of a custom style sheet, and generic attributes, such as JavaScript support. Individual attributes are set using the setAttribute() function. The WebAttribute enum further describes each attribute.

Each QWebEnginePage object has its own QWebEngineSettings object, which configures the settings for that page. If a setting is not configured for a web engine page, it is looked up in the settings of the profile the page belongs to.

See also QWebEnginePage::settings() and QWebEngineView::settings().

## Member Type Documentation

### enum QWebEngineSettings::FontFamily

This enum describes the generic font families defined by CSS 2. For more information see the CSS standard.

Constant | Value | Description
--- | --- | ---
`QWebEngineSettings::StandardFont` | `0` |
`QWebEngineSettings::FixedFont` | `1` |
`QWebEngineSettings::SerifFont` | `2` |
`QWebEngineSettings::SansSerifFont` | `3` |
`QWebEngineSettings::CursiveFont` | `4` |
`QWebEngineSettings::FantasyFont` | `5` |
`QWebEngineSettings::PictographFont` | `6` | (added in Qt 5.7)

### enum QWebEngineSettings::FontSize

This enum describes the font sizes configurable through QWebEngineSettings:

Constant | Value | Description
--- | --- | ---
`QWebEngineSettings::MinimumFontSize` | `0` | The hard minimum font size.
`QWebEngineSettings::MinimumLogicalFontSize` | `1` | The minimum logical font size that is applied when zooming out.
`QWebEngineSettings::DefaultFontSize` | `2` | The default font size for regular text.
`QWebEngineSettings::DefaultFixedFontSize` | `3` | The default font size for fixed-pitch text.

### enum QWebEngineSettings::UnknownUrlSchemePolicy

This enum describes how navigation requests to URLs with unknown schemes are handled.

Constant | Value | Description
--- | --- | ---
`QWebEngineSettings::DisallowUnknownUrlSchemes` | `1` | Disallows all navigation requests to URLs with unknown schemes.
`QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction` | `2` | Allows navigation requests to URLs with unknown schemes that are issued from user-interaction (like a mouse-click), whereas other navigation requests (for example from JavaScript) are suppressed.
`QWebEngineSettings::AllowAllUnknownUrlSchemes` | `3` | Allows all navigation requests to URLs with unknown schemes.

This enum was introduced or modified in Qt 5.11.

See also unknownUrlSchemePolicy, setUnknownUrlSchemePolicy, and resetUnknownUrlSchemePolicy.

### enum QWebEngineSettings::WebAttribute

This enum type specifies settings for web pages:

Constant | Value | Description
--- | --- | ---
`QWebEngineSettings::AutoLoadImages` | `0` | Automatically dowloads images for web pages. When this setting is disabled, images are loaded from the cache. Enabled by default.
`QWebEngineSettings::JavascriptEnabled` | `1` | Enables the running of JavaScript programs. Enabled by default.
`QWebEngineSettings::JavascriptCanOpenWindows` | `2` | Allows JavaScript programs to open popup windows without user interaction. Enabled by default.
`QWebEngineSettings::JavascriptCanAccessClipboard` | `3` | Allows JavaScript programs to read from and write to the clipboard. Writing to the clipboard is always allowed if it is specifically requested by the user. See JavascriptCanPaste to also allow pasting the content of the clipboard content from JavaScript. Disabled by default.
`QWebEngineSettings::LinksIncludedInFocusChain` | `4` | Includes hyperlinks in the keyboard focus chain. Enabled by default.
`QWebEngineSettings::LocalStorageEnabled` | `5` | Enables support for the HTML 5 local storage feature. Enabled by default.

`QWebEngineSettings::LocalContentCanAccessRemoteUrls`

`6`

Allows locally loaded documents to ignore cross-origin rules so that they can access remote resources that would normally be blocked, because all remote resources are considered cross-origin for a local file. Remote access that would not be blocked by cross-origin rules is still possible when this setting is disabled (default). Note that disabling this setting does not stop XMLHttpRequests or media elements in local files from accessing remote content. Basically, it only stops some HTML subresources, such as scripts, and therefore disabling this setting is not a safety mechanism.

`QWebEngineSettings::XSSAuditingEnabled` | `7` | Monitors load requests for cross-site scripting attempts. Suspicious scripts are blocked and reported in the inspector's JavaScript console. Disabled by default, because it might negatively affect performance.

`QWebEngineSettings::SpatialNavigationEnabled`

`8`

Enables the Spatial Navigation feature, which means the ability to navigate between focusable elements, such as hyperlinks and form controls, on a web page by using the Left, Right, Up and Down arrow keys. For example, if a user presses the Right key, heuristics determine whether there is an element they might be trying to reach towards the right and which element they probably want. Disabled by default.

`QWebEngineSettings::LocalContentCanAccessFileUrls` | `9` | Allows locally loaded documents to access other local URLs. Enabled by default.
`QWebEngineSettings::HyperlinkAuditingEnabled` | `10` | Enables support for the `ping` attribute for hyperlinks. Disabled by default.
`QWebEngineSettings::ScrollAnimatorEnabled` | `11` | Enables animated scrolling. Disabled by default.
`QWebEngineSettings::ErrorPageEnabled` | `12` | Enables displaying the built-in error pages of Chromium. Enabled by default.
`QWebEngineSettings::PluginsEnabled` | `13` | Enables support for Pepper plugins, such as the Flash player. Disabled by default. See also Pepper Plugin API. (Added in Qt 5.6)
`QWebEngineSettings::FullScreenSupportEnabled` | `14` | Enables fullscreen support in an application. Disabled by default. (Added in Qt 5.6)
`QWebEngineSettings::ScreenCaptureEnabled` | `15` | Enables screen capture in an application. Disabled by default. (Added in Qt 5.7)
`QWebEngineSettings::WebGLEnabled` | `16` | Enables support for HTML 5 WebGL. Enabled by default if available. (Added in Qt 5.7)
`QWebEngineSettings::Accelerated2dCanvasEnabled` | `17` | Specifies whether the HTML5 2D canvas should be a OpenGL framebuffer. This makes many painting operations faster, but slows down pixel access. Enabled by default if available. (Added in Qt 5.7)
`QWebEngineSettings::AutoLoadIconsForPage` | `18` | Automatically downloads icons for web pages. Enabled by default. (Added in Qt 5.7)
`QWebEngineSettings::TouchIconsEnabled` | `19` | Enables support for touch icons and precomposed touch icons Disabled by default. (Added in Qt 5.7)
`QWebEngineSettings::FocusOnNavigationEnabled` | `20` | Gives focus to the view associated with the page, whenever a navigation operation occurs (load, stop, reload, reload and bypass cache, forward, backward, set content, and so on). Disabled by default. (Added in Qt 5.8)
`QWebEngineSettings::PrintElementBackgrounds` | `21` | Turns on printing of CSS backgrounds when printing a web page. Enabled by default. (Added in Qt 5.8)
`QWebEngineSettings::AllowRunningInsecureContent` | `22` | By default, HTTPS pages cannot run JavaScript, CSS, plugins or web-sockets from HTTP URLs. This provides an override to get the old insecure behavior. Disabled by default. (Added in Qt 5.8)
`QWebEngineSettings::AllowGeolocationOnInsecureOrigins` | `23` | Since Qt 5.7, only secure origins such as HTTPS have been able to request Geolocation features. This provides an override to allow non secure origins to access Geolocation again. Disabled by default. (Added in Qt 5.9)
`QWebEngineSettings::AllowWindowActivationFromJavaScript` | `24` | Allows activating windows by using the window.focus() JavaScript method. Disabled by default. (Added in Qt 5.10)
`QWebEngineSettings::ShowScrollBars` | `25` | Shows scroll bars. Enabled by default. (Added in Qt 5.10)
`QWebEngineSettings::PlaybackRequiresUserGesture` | `26` | Inhibits playback of media content until the user interacts with the page. This is similar to how Chrome on Android behaves, while the default behavior when it is disabled is similar to Chrome on desktops. (Added in Qt 5.11)
`QWebEngineSettings::JavascriptCanPaste` | `28` | Enables JavaScript `execCommand("paste")`. This also requires enabling JavascriptCanAccessClipboard. Disabled by default. (Added in Qt 5.11)
`QWebEngineSettings::WebRTCPublicInterfacesOnly` | `27` | Limits WebRTC to public IP addresses only. When disabled WebRTC may also use local network IP addresses, but remote hosts can also see your local network IP address. Disabled by default. (Added in Qt 5.11)

## Member Function Documentation

### `[static]` QWebEngineSettings *QWebEngineSettings::defaultSettings()

Returns the settings for a web engine page that belongs to the default profile. All web pages not specifically created with another profile belong to the default profile.

### QString QWebEngineSettings::defaultTextEncoding() const

See also setDefaultTextEncoding().

### QString QWebEngineSettings::fontFamily(QWebEngineSettings::FontFamily which) const

See also setFontFamily().

### int QWebEngineSettings::fontSize(QWebEngineSettings::FontSize type) const

See also setFontSize().

### `[static]` QWebEngineSettings *QWebEngineSettings::globalSettings()

### void QWebEngineSettings::resetAttribute(QWebEngineSettings::WebAttribute attr)

### void QWebEngineSettings::resetFontFamily(QWebEngineSettings::FontFamily which)

### void QWebEngineSettings::resetFontSize(QWebEngineSettings::FontSize type)

### void QWebEngineSettings::resetUnknownUrlSchemePolicy()

### void QWebEngineSettings::setAttribute(QWebEngineSettings::WebAttribute attr, bool on)

### void QWebEngineSettings::setDefaultTextEncoding(const QString &encoding)

See also defaultTextEncoding().

### void QWebEngineSettings::setFontFamily(QWebEngineSettings::FontFamily which, const QString &family)

See also fontFamily().

### void QWebEngineSettings::setFontSize(QWebEngineSettings::FontSize type, int size)

See also fontSize().

### void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy)

See also unknownUrlSchemePolicy().

### bool QWebEngineSettings::testAttribute(QWebEngineSettings::WebAttribute attr) const

### QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const

See also setUnknownUrlSchemePolicy().