QWebEngineSettings — PyQt Documentation v6.9.0 (original) (raw)
PyQt6.QtWebEngineCore.QWebEngineSettings
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, 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()QWebEngineView::settings().
Enums¶
FontFamily
This enum describes the generic font families defined by CSS 2. For more information see the CSS standard.
Member | Value | Description |
---|---|---|
CursiveFont | TODO | TODO |
FantasyFont | TODO | TODO |
FixedFont | TODO | TODO |
PictographFont | 6 | (added in Qt 5.7, deprecated Qt 6.4) |
SansSerifFont | TODO | TODO |
SerifFont | TODO | TODO |
StandardFont | TODO | TODO |
FontSize
This enum describes the font sizes configurable through QWebEngineSettings:
Member | Value | Description |
---|---|---|
DefaultFixedFontSize | 3 | The default font size for fixed-pitch text. |
DefaultFontSize | 2 | The default font size for regular text. |
MinimumFontSize | 0 | The hard minimum font size. |
MinimumLogicalFontSize | 1 | The minimum logical font size that is applied when zooming out. |
ImageAnimationPolicy
This enum describes how an image animation should be handled when the image frames are rendered for animation.
Member | Value | Description |
---|---|---|
Allow | 1 | Allows image animation when the image frames are rendered. |
AnimateOnce | 2 | Animate the image once when the image frames are rendered. |
Disallow | 3 | Disallows image animation when the image frames are rendered. |
UnknownUrlSchemePolicy
This enum describes how navigation requests to URLs with unknown schemes are handled.
Member | Value | Description |
---|---|---|
AllowAllUnknownUrlSchemes | 3 | Allows all navigation requests to URLs with unknown schemes. |
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. |
DisallowUnknownUrlSchemes | 1 | Disallows all navigation requests to URLs with unknown schemes. |
WebAttribute
This enum type specifies settings for web pages:
Member | Value | Description |
---|---|---|
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) |
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) |
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) |
AllowWindowActivationFromJavaScript | 24 | Allows activating windows by using the window.focus() JavaScript method. Disabled by default. (Added in Qt 5.10) |
AutoLoadIconsForPage | 18 | Automatically downloads icons for web pages. Enabled by default. (Added in Qt 5.7) |
AutoLoadImages | 0 | Automatically dowloads images for web pages. When this setting is disabled, images are loaded from the cache. Enabled by default. |
DnsPrefetchEnabled | 29 | Specifies whether WebEngine will try to pre-fetch DNS entries to speed up browsing. Disabled by default. (Added in Qt 5.12) |
ErrorPageEnabled | 12 | Enables displaying the built-in error pages of Chromium. Enabled by default. |
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) |
ForceDarkMode | 33 | Specifies that all web contents will be rendered using a dark theme. For more information, see Auto dark theme. Disabled by default. (Added in Qt 6.7) |
FullScreenSupportEnabled | 14 | Enables fullscreen support in an application. Disabled by default. (Added in Qt 5.6) |
HyperlinkAuditingEnabled | 10 | Enables support for the ping attribute for hyperlinks. Disabled by default. |
JavascriptCanAccessClipboard | 3 | Allows JavaScript programs to write (copy) sanitized content to the clipboard. A sanitized write is done with the write and writeText JavaScript Clipboard API calls and must be accompanied by user action. Unsanitized writes, and reading from the clipboard, are enabled by JavascriptCanPaste. Prior to Chromium version 81, this setting enabled all clipboard writes. Since unrestricted clipboard access is a potential security concern, it is recommended that applications leave this disabled and instead respond to ClipboardReadWrite feature permission requests. Disabled by default. |
JavascriptCanOpenWindows | 2 | Allows JavaScript programs to open popup windows without user interaction. Enabled by default. |
JavascriptCanPaste | 28 | Allows JavaScript programs to read (paste) from the clipboard and to write unsanitized content. A sanitized write is done with the write and writeText JavaScript Clipboard API calls and must be accompanied by user action; unsanitized writes are any writes which do not meet these criteria. For this setting to have any effect, JavascriptCanAccessClipboard must also be enabled. Since unrestricted clipboard access is a potential security concern, it is recommended that applications leave this disabled and instead respond to ClipboardReadWrite feature permission requests. Disabled by default. (Added in Qt 5.11) |
JavascriptEnabled | 1 | Enables the running of JavaScript programs in the MainWorld. Enabled by default. |
LinksIncludedInFocusChain | 4 | Includes hyperlinks in the keyboard focus chain. Enabled by default. |
LocalContentCanAccessFileUrls | 9 | Allows locally loaded documents to access other local URLs. Disabling this makes QtWebEngine behave more like Chrome and Firefox does by default. Enabled by default. |
LocalContentCanAccessRemoteUrls | 6 | Allows local origin documents to access remote resources that would normally be blocked. Disabled by default. Note DnsPrefetchEnabled below operates independently of this setting, and can if enabled, cause remote accesses from local content. |
LocalStorageEnabled | 5 | Enables support for the HTML 5 local storage feature. Enabled by default. |
NavigateOnDropEnabled | 31 | Specifies that navigations can be triggered by dropping URLs on the view. Enabled by default. (Added in Qt 6.4) |
PdfViewerEnabled | 30 | Specifies that PDF documents will be opened in the internal PDF viewer instead of being downloaded. Enabled by default. (Added in Qt 5.13) |
PlaybackRequiresUserGesture | 26 | Inhibits playback of media content until the user interacts with the page. By default, WebEngine uses Chromium settings, as described in Autoplay Policy Changes. This is similar to how Chrome on Android behaves, while the default behavior when it is disabled is similar to Chrome on desktops. To overwrite the default behavior, disable this setting. (Added in Qt 5.11) |
PluginsEnabled | 13 | Enables support for Pepper plugins, such as the Flash player. Disabled by default. |
PreferCSSMarginsForPrinting | 35 | Turns on preferring CSS margins over the margins of the specified QPageLayout. Disabled by default. (Added in Qt 6.9) |
PrintElementBackgrounds | 21 | Turns on printing of CSS backgrounds when printing a web page. Enabled by default. (Added in Qt 5.8) |
PrintHeaderAndFooter | 34 | Specifies that printing results will contain basic page information (URL, title, date, page number) in header and footer area. It is the embedder’s responsibility to provide enough space for these texts by setting proper top and bottom margins. Disabled by default. (Added in Qt 6.9) |
ReadingFromCanvasEnabled | 32 | Specifies that reading from all canvas elements is enabled. This setting will have impact on all HTML5 canvas elements irrespective of origin, and can be disabled to prevent canvas fingerprinting. Enabled by default. (Added in Qt 6.6) |
ScreenCaptureEnabled | 15 | Enables screen capture in an application. Disabled by default. (Added in Qt 5.7) |
ScrollAnimatorEnabled | 11 | Enables animated scrolling. Disabled by default. |
ShowScrollBars | 25 | Shows scroll bars. Enabled by default. (Added in Qt 5.10) |
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. |
TouchEventsApiEnabled | 36 | Enables support for JavaScript touch events API, meaning ontouchstart, ontouchend and ontouchmove handlers will be present in the document.window object. Enabled by default if a touch device detected by the system and disabled otherwise. (Added in Qt 6.9) Note that some websites use this API to decide whether they run on a mobile device or on desktop and base their design on it. This can cause unwanted results on touchscreen laptops or other setups that emulate a fake touch device. |
TouchIconsEnabled | 19 | Enables support for touch icons and precomposed touch icons Disabled by default. (Added in Qt 5.7) |
WebGLEnabled | 16 | Enables support for HTML 5 WebGL. Enabled by default if available. (Added in Qt 5.7) |
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) |
XSSAuditingEnabled | 7 | Obsolete and has no effect. |
Methods¶
defaultTextEncoding() → str
Returns the default text encoding.
fontFamily(FontFamily) → str
Returns the actual font family for the specified generic font family, which.
fontSize(FontSize) → int
Returns the default font size for type in pixels.
imageAnimationPolicy() → ImageAnimationPolicy
Returns the currently selected policy for handling image animation when the image frames are rendered. Default is Allow.
resetAttribute(WebAttribute)
Resets the setting of attribute to the value specified in the profile that the page belongs to.
resetFontFamily(FontFamily)
Resets the actual font family specified by which to the one specified in the profile that the page belongs to.
resetFontSize(FontSize)
Resets the font size for type to the size specified in the profile that the page belongs to.
resetImageAnimationPolicy()
Removes the policy for handling image animation.
resetUnknownUrlSchemePolicy()
Removes the policy for handling navigation requests to URLs with unknown schemes.
setAttribute(WebAttribute, bool)
Enables or disables the specified attribute feature depending on the value of on.
setDefaultTextEncoding(Optional[str])
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.
setFontFamily(FontFamily, Optional[str])
TODO
setFontSize(FontSize, int)
Sets the font size for type to size in pixels.
setImageAnimationPolicy(ImageAnimationPolicy)
Sets the policy for handling image animation when the image frames are rendered to policy. Default is Allow.
setUnknownUrlSchemePolicy(UnknownUrlSchemePolicy)
Sets the policy for handling navigation requests to URLs with unknown schemes to policy. Default is AllowUnknownUrlSchemesFromUserInteraction.
testAttribute(WebAttribute) → bool
Returns true
if attribute is enabled; otherwise returns false
.
unknownUrlSchemePolicy() → UnknownUrlSchemePolicy
Returns the currently selected policy for handling navigation requests to URLs with unknown schemes. Default is AllowUnknownUrlSchemesFromUserInteraction.