QWebEngineSettings 類

The QWebEngineSettings 類提供對象以存儲設置,用於 QWebEnginePage . 更多...

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

公共類型

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

公共函數

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

靜態公共成員

QWebEngineSettings * defaultSettings ()

詳細描述

The QWebEngineSettings 類提供對象以存儲設置,用於 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 () 函數。 WebAttribute 枚舉進一步描述各屬性。

每個 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.

另請參閱 QWebEnginePage::settings () 和 QWebEngineView::settings ().

成員類型文檔編製

enum QWebEngineSettings:: FontFamily

此枚舉描述由 CSS 2 定義的一般字體係列。更多信息見 CSS 標準 .

常量 描述
QWebEngineSettings::StandardFont 0
QWebEngineSettings::FixedFont 1
QWebEngineSettings::SerifFont 2
QWebEngineSettings::SansSerifFont 3
QWebEngineSettings::CursiveFont 4
QWebEngineSettings::FantasyFont 5
QWebEngineSettings::PictographFont 6 (在 Qt 5.7 添加)

enum QWebEngineSettings:: FontSize

此枚舉描述字體大小, 可配置透過 QWebEngineSettings :

常量 描述
QWebEngineSettings::MinimumFontSize 0 硬最小字體大小。
QWebEngineSettings::MinimumLogicalFontSize 1 當縮小時應用的最小邏輯字體大小。
QWebEngineSettings::DefaultFontSize 2 用於常規文本的默認字體大小。
QWebEngineSettings::DefaultFixedFontSize 3 用於固定間距文本的默認字體大小。

enum QWebEngineSettings:: WebAttribute

此枚舉類型指定網頁設置:

常量 描述
QWebEngineSettings::AutoLoadImages 0 自動下載網頁圖像。當禁用此設置時,將從緩存加載圖像。默認啓用。
QWebEngineSettings::JavascriptEnabled 1 Enables the running of JavaScript programs. Enabled by default.
QWebEngineSettings::JavascriptCanOpenWindows 2 允許 JavaScript 程序打開彈齣窗口 (無需用戶交互)。默認啓用。
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. Disabled by default.
QWebEngineSettings::LinksIncludedInFocusChain 4 包括鍵盤聚焦鏈中的超鏈接。默認啓用。
QWebEngineSettings::LocalStorageEnabled 5 啓用支持 HTML 5 本地存儲特徵。默認啓用。
QWebEngineSettings::LocalContentCanAccessRemoteUrls 6 允許本地加載文檔忽略跨源規則,以便它們通常可以訪問被阻塞的遠程資源,因為所有遠程資源都被認為是跨源的對於本地文件。不被跨源規則阻塞的遠程訪問仍是可能的,當此設置被禁用時 (默認)。注意,禁用此設置不會停止 XMLHttpRequest 或本地文件中的媒體元素訪問遠程內容。基本上,僅停止一些 HTML 子資源 (譬如:腳本),因此禁用此設置不是安全機製。
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 啓用空間導航特徵,這意味著能夠通過使用左、右、上、下箭頭鍵在網頁可聚焦元素 (譬如:超鏈接和錶單控件) 之間導航。例如,若用戶按下右箭頭鍵,試探確定是否試著朝右有可能到達的元素,及它們可能想要到達哪個元素。默認禁用。
QWebEngineSettings::LocalContentCanAccessFileUrls 9 允許本地加載文檔訪問其它本地 URL。默認啓用。
QWebEngineSettings::HyperlinkAuditingEnabled 10 啓用支持 ping 屬性為超鏈接。默認禁用。
QWebEngineSettings::ScrollAnimatorEnabled 11 啓用動畫捲動。默認禁用。
QWebEngineSettings::ErrorPageEnabled 12 啓用顯示 Chromium 的內置錯誤頁麵。默認啓用。
QWebEngineSettings::PluginsEnabled 13 啓用支持 Pepper 插件 (譬如:Flash 播放器)。默認禁用。另請參閱 Pepper 插件 API (在 Qt 5.6 添加)。
QWebEngineSettings::FullScreenSupportEnabled 14 在應用程序中啓用全屏支持。默認禁用 (在 Qt 5.6 添加)。
QWebEngineSettings::ScreenCaptureEnabled 15 在應用程序中啓用屏幕捕獲。默認禁用 (在 Qt 5.7 添加)。
QWebEngineSettings::WebGLEnabled 16 啓用支持 HTML 5 WebGL。默認啓用,若可用 (在 Qt 5.7 添加)。
QWebEngineSettings::Accelerated2dCanvasEnabled 17 指定 HTML5 2D 畫布是否應該是 OpenGL 幀緩衝。這使很多描繪操作變得更快,但會減慢像素訪問。默認啓用,若可用 (在 Qt 5.7 添加)。
QWebEngineSettings::AutoLoadIconsForPage 18 自動下載網頁圖標。默認啓用 (在 Qt 5.7 添加)。
QWebEngineSettings::TouchIconsEnabled 19 啓用支持觸摸圖標和預閤成觸摸圖標。默認禁用 (在 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). Enabled by default. (Added in Qt 5.8)
QWebEngineSettings::PrintElementBackgrounds 21 打開 CSS 背景的打印,當打印網頁時。默認啓用 (在 Qt 5.8 添加)。
QWebEngineSettings::AllowRunningInsecureContent 22 默認情況下,HTTPS 頁麵無法從 HTTP URL 運行 JavaScript、CSS、插件或 Web 套接字。這提供覆寫以獲得舊的不安全行為。默認禁用 (在 Qt 5.8 添加)。
QWebEngineSettings::AllowGeolocationOnInsecureOrigins 23 從 Qt 5.7 起,僅安全源 (譬如 HTTPS) 能夠請求地理位置特徵。這提供覆寫以允許非安全源能再次訪問地理位置。默認禁用 (在 Qt 5.9 添加)。

成員函數文檔編製

[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

返迴默認文本編碼。

另請參閱 setDefaultTextEncoding ().

QString QWebEngineSettings:: fontFamily ( FontFamily which ) const

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

另請參閱 setFontFamily ().

int QWebEngineSettings:: fontSize ( FontSize type ) const

返迴默認字體大小對於 type (以像素為單位)。

另請參閱 setFontSize ().

void QWebEngineSettings:: resetAttribute ( WebAttribute attribute )

Resets the setting of attribute to the value specified in the profile that the page belongs to.

void QWebEngineSettings:: resetFontFamily ( FontFamily which )

Resets the actual font family specified by which to the one specified in the profile that the page belongs to.

void QWebEngineSettings:: resetFontSize ( FontSize type )

Resets the font size for type to the size specified in the profile that the page belongs to.

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

啓用或禁用指定 attribute 特徵從屬值對於 on .

void QWebEngineSettings:: setDefaultTextEncoding (const QString & encoding )

指定默認文本編碼係統。

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 .

另請參閱 defaultTextEncoding ().

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

將實際字體係列設為 family 為指定一般係列, which .

另請參閱 fontFamily ().

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

設置字體大小對於 type to size (以像素為單位)。

另請參閱 fontSize ().

bool QWebEngineSettings:: testAttribute ( WebAttribute attribute ) const

返迴 true if attribute 被啓用;否則返迴 false .