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

Public Types

enum FontFamily { StandardFont, FixedFont, SerifFont, SansSerifFont, ..., PictographFont }
enum FontSize { MinimumFontSize, MinimumLogicalFontSize, DefaultFontSize, DefaultFixedFontSize }
enum WebAttribute { AutoLoadImages, JavascriptEnabled, JavascriptCanOpenWindows, JavascriptCanAccessClipboard, ..., AllowRunningInsecureContent }

Public Functions

QString defaultTextEncoding() const
QString fontFamily(FontFamily which) const
int fontSize(FontSize type) const
void resetAttribute(WebAttribute attribute)
void resetFontFamily(FontFamily which)
void resetFontSize(FontSize type)
void setAttribute(WebAttribute attribute, bool on)
void setDefaultTextEncoding(const QString &encoding)
void setFontFamily(FontFamily which, const QString &family)
void setFontSize(FontSize type, int size)
bool testAttribute(WebAttribute attribute) const

Static Public Members

QWebEngineSettings *defaultSettings()
QWebEngineSettings *globalSettings()

Detailed Description

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

Each QWebEnginePage object has its own QWebEngineSettings object, which configures the settings for that page. If a setting is not configured, then it is looked up in the global settings object, which can be accessed using globalSettings().

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.

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.

QWebEngineSettings::PictographFont6(added in Qt 5.7)

enum QWebEngineSettings::FontSize

This enum describes the font sizes configurable through QWebEngineSettings:

QWebEngineSettings::MinimumFontSize0The hard minimum font size.
QWebEngineSettings::MinimumLogicalFontSize1The minimum logical font size that is applied when zooming out.
QWebEngineSettings::DefaultFontSize2The default font size for regular text.
QWebEngineSettings::DefaultFixedFontSize3The default font size for fixed-pitch text.

enum QWebEngineSettings::WebAttribute

This enum type specifies settings for web pages:

QWebEngineSettings::AutoLoadImages0Automatically dowloads images for web pages. When this setting is disabled, images are loaded from the cache. Enabled by default.
QWebEngineSettings::JavascriptEnabled1Enables the running of JavaScript programs. Enabled by default.
QWebEngineSettings::JavascriptCanOpenWindows2Allows JavaScript programs to open popup windows without user interaction. Enabled by default.
QWebEngineSettings::JavascriptCanAccessClipboard3Allows JavaScript programs to read from and write to the clipboard. Disabled by default.
QWebEngineSettings::LinksIncludedInFocusChain4Includes hyperlinks in the keyboard focus chain. Enabled by default.
QWebEngineSettings::LocalStorageEnabled5Enables support for the HTML 5 local storage feature. Enabled by default.
QWebEngineSettings::LocalContentCanAccessRemoteUrls6Allows 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::XSSAuditingEnabled7Monitors 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::SpatialNavigationEnabled8Enables 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::LocalContentCanAccessFileUrls9Allows locally loaded documents to access other local URLs. Enabled by default.
QWebEngineSettings::HyperlinkAuditingEnabled10Enables support for the ping attribute for hyperlinks. Disabled by default.
QWebEngineSettings::ScrollAnimatorEnabled11Enables animated scrolling. Disabled by default.
QWebEngineSettings::ErrorPageEnabled12Enables displaying the built-in error pages of Chromium. Enabled by default.
QWebEngineSettings::PluginsEnabled13Enables support for Pepper plugins, such as the Flash player. Disabled by default. See also Pepper Plugin API. (Added in Qt 5.6)
QWebEngineSettings::FullScreenSupportEnabled14Enables fullscreen support in an application. Disabled by default. (Added in Qt 5.6)
QWebEngineSettings::ScreenCaptureEnabled15Enables screen capture in an application. Disabled by default. (Added in Qt 5.7)
QWebEngineSettings::WebGLEnabled16Enables support for HTML 5 WebGL. Enabled by default if available. (Added in Qt 5.7)
QWebEngineSettings::Accelerated2dCanvasEnabled17Specifies 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::AutoLoadIconsForPage18Automatically downloads icons for web pages. Enabled by default. (Added in Qt 5.7)
QWebEngineSettings::TouchIconsEnabled19Enables support for touch icons and precomposed touch icons Disabled by default. (Added in Qt 5.7)
QWebEngineSettings::FocusOnNavigationEnabled20Gives 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). Enabled by default. (Added in Qt 5.8)
QWebEngineSettings::PrintElementBackgrounds21Turns on printing of CSS backgrounds when printing a web page. Enabled by default. (Added in Qt 5.8)
QWebEngineSettings::AllowRunningInsecureContent22By 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)

Member Function Documentation

[static] QWebEngineSettings *QWebEngineSettings::defaultSettings()

Returns the default settings for the web engine page.

See also globalSettings().

QString QWebEngineSettings::defaultTextEncoding() const

Returns the default text encoding.

See also setDefaultTextEncoding().

QString QWebEngineSettings::fontFamily(FontFamily which) const

Returns the actual font family for the specified generic font family, which.

See also setFontFamily().

int QWebEngineSettings::fontSize(FontSize type) const

Returns the default font size for type in pixels.

See also setFontSize().

[static] QWebEngineSettings *QWebEngineSettings::globalSettings()

Returns the global settings object.

Any setting changed on the default object is automatically applied to all QWebEnginePage instances where the particular setting is not overridden already.

See also defaultSettings().

void QWebEngineSettings::resetAttribute(WebAttribute attribute)

Resets the setting of attribute to the value specified in the global QWebEngineSettings instance.

This function has no effect on the global QWebEngineSettings instance.

See also globalSettings().

void QWebEngineSettings::resetFontFamily(FontFamily which)

Resets the actual font family specified by which to the one set in the global QWebEngineSettings instance.

This function has no effect on the global QWebEngineSettings instance.

void QWebEngineSettings::resetFontSize(FontSize type)

Resets the font size for type to the size specified in the global settings object.

This function has no effect on the global QWebEngineSettings instance.

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

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

void QWebEngineSettings::setDefaultTextEncoding(const QString &encoding)

Specifies the default text encoding system.

The value of encoding must be a string describing an encoding such as "utf-8" or "iso-8859-1". If left empty, a default value will be used. For a more extensive list of encoding names see QTextCodec.

See also defaultTextEncoding().

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

Sets the actual font family to family for the specified generic family, which.

See also fontFamily().

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

Sets the font size for type to size in pixels.

See also fontSize().

bool QWebEngineSettings::testAttribute(WebAttribute attribute) const

Returns true if attribute is enabled; otherwise returns false.

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