内容表

上一话题

QWebEngineHistoryItem

下一话题

QWebEngineProfile

QWebEnginePage

QWebEnginePage class provides an object to view and edit web documents. 更多

Inheritance diagram of PySide2.QtWebEngineWidgets.QWebEnginePage

概要

函数

虚函数

信号

详细描述

A Web 引擎页面 保持 HTML 文档的内容、导航链接的历史及动作。

QWebEnginePage ‘s API is very similar to QWebEngineView ,仍提供常用功能像 action() (known as pageAction () 在 QWebEngineView ), triggerAction() ,和 findText() .

页面可以被加载使用 load() or setUrl() . Alternatively, if you have the HTML content readily available, you can use setHtml() . The GET method is always used to load URLs.

QWebEnginePage class also offers methods to retrieve both the URL currently loaded by the page (see url() ) as well as the URL originally requested to be loaded (see requestedUrl() ). These methods make possible the retrieval of the URL before and after a DNS resolution or a redirection occurs during the load process. The requestedUrl() also matches to the URL added to the page history ( QWebEngineHistory ) 若加载成功。

HTML 页面标题可以被访问采用 title() property. Additionally, a page may also specify an icon, which can be accessed using the icon() or its URL using the iconUrl() property. If the title or the icon changes, the corresponding titleChanged() , iconChanged() and iconUrlChanged() signals will be emitted. The zoomFactor() property enables zooming the contents of the web page by a scale factor.

loadStarted() signal is emitted when the page begins to load, whereas the loadProgress() signal is emitted whenever an element of the web page completes loading, such as an embedded image or a script. The loadFinished() signal is emitted when the page contents have been loaded completely, independent of script execution or page rendering. Its argument, either true or false ,指示加载操作是否成功。

HTML 文档被加载于 main frame 在网页中。若它引用 child frames (定义通过 <frame> or <iframe> 元素),它们被认为是内容的一部分。子级框架只可透过 JavaScript 单独访问。

网站定义 security origin for safely accessing each other’s resources for client-side scripting or databases. An origin consist of a host name, a scheme, and a port number. For example, the sites http://www.example.com/my/page.html and http://www.example.com/my/overview.html are allowed to share the same database or access each other’s documents when used in HTML frame sets and JavaScript. At the same time, http://www.malicious.com/evil.html 被阻止访问其下资源为 http://www.example.com/ ,因为它们是不同安全来源。默认情况下,本地方案像 file:// and qrc:// are considered to be in the same security origin, and can access each other’s resources. Local resources are by default restricted from accessing remote content, which means that file:// 将不能访问 http://domain.com/foo.html .

脚本可以被执行在网页通过使用 runJavaScript() , either in the main JavaScript world ,来自 web 内容的其它 JavaScript,或在它们自己的独立世界。虽然页面的 DOM 可以被访问从任何世界,但在某一世界中定义的 JavaScript 函数变量是不能从另一世界访问的。 ScriptWorldId 为此目的提供了一些预定义 ID。使用 runJavaScript() 在世界 ID 外版本如同运行脚本在 MainWorld .

FocusOnNavigationEnabled 设置可以被用于使查看关联页面自动接收聚焦,当发生导航操作时 (像加载或重新加载页面或透过历史进行导航)。

class QWebEnginePage ( [ parent=Q_NULLPTR ] )

QWebEnginePage(profile[, parent=Q_NULLPTR])

param parent

QObject

param profile

QWebEngineProfile

构造空 QWebEnginePage 采用父级 parent .

构造空 Web 引擎页面按 Web 引擎配置文件 profile 采用父级 parent .

若 profile (配置文件) 不是默认配置文件,调用者必须确保该配置文件保持存活只要页面存在。

PySide2.QtWebEngineWidgets.QWebEnginePage. WebAction

此枚举描述可以在网页上履行的动作类型。

动作才有效,当可应用时。

动作的可用性可以被确定,通过检查 isEnabled() 在返回动作通过 action() .

常量

描述

QWebEnginePage.NoWebAction

没有动作被触发。

QWebEnginePage.Back

在导航链接历史中后退导航。

QWebEnginePage.Forward

在导航链接历史中前进导航。

QWebEnginePage.Stop

停止加载当前页面。

QWebEnginePage.Reload

重新加载当前页面。

QWebEnginePage.ReloadAndBypassCache

重新加载当前页面,但不使用任何本地缓存。

QWebEnginePage.Cut

把目前选中内容剪切到剪贴板。

QWebEnginePage.Copy

把目前选中内容拷贝到剪贴板。

QWebEnginePage.Paste

从剪贴板粘贴内容。

QWebEnginePage.Undo

撤消上一编辑动作。

QWebEnginePage.Redo

重做上一编辑动作。

QWebEnginePage.SelectAll

Select all content. This action is only enabled when the page’s content is focused. The focus can be forced by the JavaScript window.focus() 调用,或 FocusOnNavigationEnabled 设置应该被启用以获得自动聚焦。

QWebEnginePage.PasteAndMatchStyle

采用当前样式从剪贴板粘贴内容。

QWebEnginePage.OpenLinkInThisWindow

在当前窗口中打开当前链接。(在 Qt 5.6 添加)

QWebEnginePage.OpenLinkInNewWindow

在新窗口中打开当前链接。要求实现 createWindow() 。(在 Qt 5.6 添加)

QWebEnginePage.OpenLinkInNewTab

在新选项卡中打开当前链接。要求实现 createWindow() 。(在 Qt 5.6 添加)

QWebEnginePage.OpenLinkInNewBackgroundTab

在新背景选项卡中打开当前链接。要求实现 createWindow() 。(在 Qt 5.7 添加)

QWebEnginePage.CopyLinkToClipboard

把当前链接拷贝到剪贴板。(在 Qt 5.6 添加)

QWebEnginePage.CopyImageToClipboard

把被点击图像拷贝到剪贴板。(在 Qt 5.6 添加)

QWebEnginePage.CopyImageUrlToClipboard

Copy the clicked image’s URL to the clipboard. (Added in Qt 5.6)

QWebEnginePage.CopyMediaUrlToClipboard

Copy the hovered audio or video’s URL to the clipboard. (Added in Qt 5.6)

QWebEnginePage.ToggleMediaControls

在展示和隐藏悬停音频或视频元素控件之间触发。(在 Qt 5.6 添加)

QWebEnginePage.ToggleMediaLoop

触发悬停音频或视频是否应在完成时循环。(在 Qt 5.6 添加)

QWebEnginePage.ToggleMediaPlayPause

触发悬停音频或视频元素的播放/暂停状态。(在 Qt 5.6 添加)

QWebEnginePage.ToggleMediaMute

静音或取消静音悬停的音频或视频元素。(在 Qt 5.6 添加)

QWebEnginePage.DownloadLinkToDisk

把当前链接下载到磁盘。要求槽为 downloadRequested() 。(在 Qt 5.6 添加)

QWebEnginePage.DownloadImageToDisk

把被突显图像下载到磁盘。要求槽为 downloadRequested() 。(在 Qt 5.6 添加)

QWebEnginePage.DownloadMediaToDisk

将悬停音频或视频下载到磁盘。要求槽用于 downloadRequested() 。(在 Qt 5.6 添加)

QWebEnginePage.InspectElement

触发任何附加 Web 审查器以审查高亮元素。(在 Qt 5.6 添加)

QWebEnginePage.ExitFullScreen

退出全屏模式。(在 Qt 5.6 添加)

QWebEnginePage.RequestClose

请求关闭网页。若定义, window.onbeforeunload 处理程序运行,且用户可以确认或拒绝关闭页面。若有确认关闭请求, windowCloseRequested 被发射。(在 Qt 5.6 添加)

QWebEnginePage.Unselect

清零当前选定。(在 Qt 5.7 添加)

QWebEnginePage.SavePage

把当前页面保存到磁盘。MHTML 是用于把网页存储在磁盘的默认格式。要求槽为 downloadRequested() 。(在 Qt 5.7 添加)

QWebEnginePage.ViewSource

在新选项卡中展示当前页面的源代码。要求实现 createWindow() . (Added in Qt 5.8)

QWebEnginePage.ToggleBold

触发选定或光标位置处的粗体。要求 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.ToggleItalic

触发选定或光标位置处的斜体。要求 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.ToggleUnderline

触发选定或光标位置处的下划线。要求 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.ToggleStrikethrough

触发选定或光标位置处的删除线。要求 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.AlignLeft

左对齐行所包含的选定或光标。需要 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.AlignCenter

居中对齐行所包含的选定或光标。需要 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.AlignRight

右对齐行所包含的选定或光标。需要 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.AlignJustified

拉伸包含选定或光标的行,以使每行拥有相等宽度。要求 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.Indent

缩进包含选定或光标的行。要求 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.Outdent

伸出包含选定或光标的行。要求 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.InsertOrderedList

将有序列表插入在当前光标位置处,删除当前选定。要求 contenteditable="true" 。(在 Qt 5.10 添加)

QWebEnginePage.InsertUnorderedList

将无序列表插入在当前光标位置处,删除当前选定。要求 contenteditable="true" 。(在 Qt 5.10 添加)

PySide2.QtWebEngineWidgets.QWebEnginePage. FindFlag

此枚举描述的选项可用于 findText() 函数。可以 OR 组合下表中的选项:

常量

描述

QWebEnginePage.FindBackward

向后搜索,而不是向前。

QWebEnginePage.FindCaseSensitively

默认情况下 findText() works case insensitive. Specifying this option changes the behavior to a case sensitive find operation.

PySide2.QtWebEngineWidgets.QWebEnginePage. WebWindowType

此枚举描述可以创建的窗口类型通过 createWindow() 函数:

常量

描述

QWebEnginePage.WebBrowserWindow

完整 Web 浏览器窗口。

QWebEnginePage.WebBrowserTab

Web 浏览器选项卡。

QWebEnginePage.WebDialog

没有装饰的窗口。

QWebEnginePage.WebBrowserBackgroundTab

Web 浏览器选项卡不隐藏当前可见 WebEngineView 。(在 Qt 5.7 添加)

PySide2.QtWebEngineWidgets.QWebEnginePage. PermissionPolicy

此枚举描述用户可以为数据或设备访问设置的权限策略:

常量

描述

QWebEnginePage.PermissionUnknown

用户是否授予或拒绝权限未知。

QWebEnginePage.PermissionGrantedByUser

用户已授予权限。

QWebEnginePage.PermissionDeniedByUser

用户已拒绝权限。

PySide2.QtWebEngineWidgets.QWebEnginePage. NavigationType

此枚举描述导航请求类型:

常量

描述

QWebEnginePage.NavigationTypeLinkClicked

导航请求由点击链接产生。

QWebEnginePage.NavigationTypeTyped

导航请求由明确加载 URL 产生。

QWebEnginePage.NavigationTypeFormSubmitted

导航请求由表单提交产生。

QWebEnginePage.NavigationTypeBackForward

导航请求由后退或前进动作产生。

QWebEnginePage.NavigationTypeReload

导航请求由重新加载动作产生。

QWebEnginePage.NavigationTypeRedirect

导航请求由内容或服务器控制重定向产生。这还包括自动重新加载。(在 Qt 5.14 添加)

QWebEnginePage.NavigationTypeOther

导航请求由上述未涵盖的其它手段触发。

PySide2.QtWebEngineWidgets.QWebEnginePage. Feature

此枚举描述用户可能被要求授予 (或拒绝) 访问的平台特征访问类别:

常量

描述

QWebEnginePage.Notifications

最终用户的 Web 通知。

QWebEnginePage.Geolocation

定位硬件或服务。

QWebEnginePage.MediaAudioCapture

音频捕获设备 (譬如:麦克风)。

QWebEnginePage.MediaVideoCapture

视频设备 (譬如:摄像头)。

QWebEnginePage.MediaAudioVideoCapture

音频和视频捕获设备。

QWebEnginePage.MouseLock

鼠标锁定,将鼠标指针锁定到 Web 视图 (通常用于游戏)。

QWebEnginePage.DesktopVideoCapture

Video output capture, that is, the capture of the user’s display, for screen sharing purposes for example. (Added in Qt 5.10)

QWebEnginePage.DesktopAudioVideoCapture

音频和视频输出捕获。(在 Qt 5.10 添加)

PySide2.QtWebEngineWidgets.QWebEnginePage. FileSelectionMode

此枚举指示实现的 chooseFiles() function should return only one file or may return multiple files:

常量

描述

QWebEnginePage.FileSelectOpen

只返回一个文件名。

QWebEnginePage.FileSelectOpenMultiple

返回多个文件名。

另请参阅

chooseFiles()

PySide2.QtWebEngineWidgets.QWebEnginePage. JavaScriptConsoleMessageLevel

此枚举描述了 JavaScript 控制台消息,可以拥有的不同严重级别:

常量

描述

QWebEnginePage.InfoMessageLevel

消息为纯情报且可以被安全忽略。

QWebEnginePage.WarningMessageLevel

消息告知可能需要关注的意外行为 (或错误)。

QWebEnginePage.ErrorMessageLevel

消息指示出现错误。

PySide2.QtWebEngineWidgets.QWebEnginePage. RenderProcessTerminationStatus

此枚举描述渲染进程终止状态:

常量

描述

QWebEnginePage.NormalTerminationStatus

渲染进程正常终止。

QWebEnginePage.AbnormalTerminationStatus

渲染进程以非零退出状态终止。

QWebEnginePage.CrashedTerminationStatus

渲染进程崩溃 (例如:由于分段故障)。

QWebEnginePage.KilledTerminationStatus

渲染进程被杀除,例如被 SIGKILL 或被任务管理器杀除。

PySide2.QtWebEngineWidgets.QWebEnginePage. acceptNavigationRequest ( url , type , isMainFrame )
参数
返回类型

bool

此函数被调用在接收请求以导航到指定 url 通过指定导航类型 type . isMainFrame 指示请求对应主框架或子级框架。若函数返回 true ,导航请求被接受且 url 被加载。默认实现接受所有导航请求。

此函数被调用为加前缀的绝对 URL 采用 http:// or https:// 及为无法识别方案,譬如 mailto: ,其会被处理通过 QDesktopServices 若接受。要在接收请求导航到本地 URL 时也调用此函数,URL 前缀采用 http:// .

导航请求可以被委托给 Qt 应用程序,而不是让 HTML 处理程序引擎通过重载此函数处理它们。这是必要的,当把 HTML 文档用作用户界面的一部分,且不显示外部数据时 (例如:当显示结果列表时)。

注意

加载进程开始且 loadStarted() signal is emitted before 请求被接受或拒绝。因此, loadFinished() 信号返回 false 是可预期的即使在委派请求后。

QWebEngineUrlRequestInterceptor 类提供用于拦截和操纵请求的进一步选项。

PySide2.QtWebEngineWidgets.QWebEnginePage. action ( action )
参数

action WebAction

返回类型

QAction

返回 QAction 为指定 WebAction action .

动作归 QWebEnginePage 但可以通过改变其特性定制外观。

QWebEnginePage 还负责实现动作,以便触发时在页面履行相应动作。

另请参阅

triggerAction()

PySide2.QtWebEngineWidgets.QWebEnginePage. audioMutedChanged ( muted )
参数

muted bool

PySide2.QtWebEngineWidgets.QWebEnginePage. authenticationRequired ( requestUrl , authenticator )
参数
  • requestUrl QUrl

  • authenticator QAuthenticator

PySide2.QtWebEngineWidgets.QWebEnginePage. backgroundColor ( )
返回类型

QColor

PySide2.QtWebEngineWidgets.QWebEnginePage. certificateError ( certificateError )
参数

certificateError QWebEngineCertificateError

返回类型

bool

此函数被调用,当加载给定请求时引发无效证书错误。

certificateError 参数包含证书和错误细节的有关信息。

返回 true 忽略错误并完成请求。返回 false 停止加载请求。

注意

若错误被成功延期,返回值会被忽略。

PySide2.QtWebEngineWidgets.QWebEnginePage. chooseFiles ( mode , oldFiles , acceptedMimeTypes )
参数
  • mode FileSelectionMode

  • oldFiles – 字符串列表

  • acceptedMimeTypes – 字符串列表

返回类型

字符串列表

This function is called when the web content requests a file name, for example as a result of the user clicking on a file upload button in an HTML form.

mode indicates whether only one file or multiple files are expected to be returned.

A suggested filename may be provided as the first entry of oldFiles . acceptedMimeTypes is ignored by the default implementation, but might be used by overrides.

PySide2.QtWebEngineWidgets.QWebEnginePage. contentsSize ( )
返回类型

QSizeF

PySide2.QtWebEngineWidgets.QWebEnginePage. contentsSizeChanged ( size )
参数

size QSizeF

PySide2.QtWebEngineWidgets.QWebEnginePage. contextMenuData ( )
返回类型

QWebEngineContextMenuData

返回当前上下文菜单的有关额外数据。它仅保证是有效的在调用 contextMenuEvent() handler of the associated QWebEngineView .

PySide2.QtWebEngineWidgets.QWebEnginePage. createStandardContextMenu ( )
返回类型

QMenu

创建标准上下文菜单,当用户采用鼠标右键点击网页时展示。它被调用从默认 contextMenuEvent() handler. The popup menu’s ownership is transferred to the caller.

返回 nullptr 若上下文菜单数据未被初始化,例如:在实际不请求上下文菜单时调用它。

PySide2.QtWebEngineWidgets.QWebEnginePage. createWindow ( type )
参数

type WebWindowType

返回类型

QWebEnginePage

此函数被调用以创建新窗口,采用指定 type 。例如,当 JavaScript 程序请求在新窗口中打开文档时。

If the new window can be created, the new window’s QWebEnginePage 被返回;否则 null 指针被返回。

若网页关联视图为 QWebEngineView 对象,则默认实现把请求转发给 createWindow() ; otherwise it returns a null pointer.

注意

在通过 JavaScript 触发创建窗口的情况中,除重实现此方法外,应用程序还必须设置 JavascriptCanOpenWindows to true in order for the method to get called.

另请参阅

createWindow()

PySide2.QtWebEngineWidgets.QWebEnginePage. devToolsPage ( )
返回类型

QWebEnginePage

返回托管此页面开发者工具的页面,若有的话。

返回 nullptr 若未设置开发者工具页面。

PySide2.QtWebEngineWidgets.QWebEnginePage. download ( url [ , filename="" ] )
参数
  • url QUrl

  • filename – unicode

下载来自定位的资源,给定通过 url 到本地文件。

filename 被给定,它会被用作建议文件名。若它是相对的,则采用给定名称把文件保存在标准下载定位。若它是 null 或空 QString ,使用默认文件名。

这会发射 downloadRequested() after the download has started.

PySide2.QtWebEngineWidgets.QWebEnginePage. featurePermissionRequestCanceled ( securityOrigin , feature )
参数
  • securityOrigin QUrl

  • feature Feature

PySide2.QtWebEngineWidgets.QWebEnginePage. featurePermissionRequested ( securityOrigin , feature )
参数
  • securityOrigin QUrl

  • feature Feature

PySide2.QtWebEngineWidgets.QWebEnginePage. findText ( arg__1 , arg__2 , arg__3 )
参数
  • arg__1 – unicode

  • arg__2 FindFlags

  • arg__3 PyObject

PySide2.QtWebEngineWidgets.QWebEnginePage. findText ( subString [ , options=QWebEnginePage.FindFlags() ] )
参数
  • subString – unicode

  • options FindFlags

PySide2.QtWebEngineWidgets.QWebEnginePage. fullScreenRequested ( fullScreenRequest )
参数

fullScreenRequest QWebEngineFullScreenRequest

PySide2.QtWebEngineWidgets.QWebEnginePage. geometryChangeRequested ( geom )
参数

geom QRect

PySide2.QtWebEngineWidgets.QWebEnginePage. hasSelection ( )
返回类型

bool

PySide2.QtWebEngineWidgets.QWebEnginePage. history ( )
返回类型

QWebEngineHistory

Returns a pointer to the view’s history of navigated web pages.

PySide2.QtWebEngineWidgets.QWebEnginePage. icon ( )
返回类型

QIcon

PySide2.QtWebEngineWidgets.QWebEnginePage. iconChanged ( icon )
参数

icon QIcon

PySide2.QtWebEngineWidgets.QWebEnginePage. iconUrl ( )
返回类型

QUrl

PySide2.QtWebEngineWidgets.QWebEnginePage. iconUrlChanged ( url )
参数

url QUrl

PySide2.QtWebEngineWidgets.QWebEnginePage. inspectedPage ( )
返回类型

QWebEnginePage

返回此页面正在审查的页面,若有的话。

返回 nullptr 如果此页面不是开发者工具页面。

PySide2.QtWebEngineWidgets.QWebEnginePage. isAudioMuted ( )
返回类型

bool

PySide2.QtWebEngineWidgets.QWebEnginePage. isVisible ( )
返回类型

bool

PySide2.QtWebEngineWidgets.QWebEnginePage. javaScriptAlert ( securityOrigin , msg )
参数
  • securityOrigin QUrl

  • msg – unicode

此函数被调用,每当 JavaScript 程序运行在附属框架采用 securityOrigin 调用 alert() 函数采用消息 msg .

默认实现展示消息, msg ,采用 information .

PySide2.QtWebEngineWidgets.QWebEnginePage. javaScriptConfirm ( securityOrigin , msg )
参数
  • securityOrigin QUrl

  • msg – unicode

返回类型

bool

此函数被调用,每当 JavaScript 程序运行在附属框架采用 securityOrigin 调用 confirm() 函数采用消息 msg 。返回 true 若用户确认消息;否则返回 false .

它也会被调用当 onbeforeunload 处理程序请求确认在离开页面之前。

默认实现执行查询使用 information with Ok and Cancel 按钮。

PySide2.QtWebEngineWidgets.QWebEnginePage. javaScriptConsoleMessage ( level , message , lineNumber , sourceID )
参数

This function is called when a JavaScript program tries to print the message to the web browser’s console.

For example, in case of evaluation errors the source URL may be provided in sourceID as well as the lineNumber .

level indicates the severity of the event that triggered the message. That is, whether it was triggered by an error or a less severe event.

Since Qt 5.6, the default implementation logs the messages in a js logging category .

另请参阅

控制台日志

PySide2.QtWebEngineWidgets.QWebEnginePage. javaScriptPrompt ( securityOrigin , msg , defaultValue , result )
参数
  • securityOrigin QUrl

  • msg – unicode

  • defaultValue – unicode

  • result – unicode

返回类型

bool

此函数被调用,每当 JavaScript 程序运行在附属框架采用 securityOrigin tries to prompt the user for input. The program may provide an optional message, msg , as well as a default value for the input in defaultValue .

If the prompt was cancelled by the user, the implementation should return false ; otherwise the result should be written to result and true should be returned. If the prompt was not cancelled by the user, the implementation should return true and the result string must not be null.

默认实现使用 getText() .

PySide2.QtWebEngineWidgets.QWebEnginePage. linkHovered ( url )
参数

url – unicode

PySide2.QtWebEngineWidgets.QWebEnginePage. load ( url )
参数

url QUrl

PySide2.QtWebEngineWidgets.QWebEnginePage. load ( request )
参数

request QWebEngineHttpRequest

PySide2.QtWebEngineWidgets.QWebEnginePage. loadFinished ( ok )
参数

ok bool

PySide2.QtWebEngineWidgets.QWebEnginePage. loadProgress ( progress )
参数

progress int

PySide2.QtWebEngineWidgets.QWebEnginePage. loadStarted ( )
PySide2.QtWebEngineWidgets.QWebEnginePage. pdfPrintingFinished ( filePath , success )
参数
  • filePath – unicode

  • success bool

PySide2.QtWebEngineWidgets.QWebEnginePage. print ( arg__1 , arg__2 )
参数
  • arg__1 QPrinter

  • arg__2 PyObject

PySide2.QtWebEngineWidgets.QWebEnginePage. printRequested ( )
PySide2.QtWebEngineWidgets.QWebEnginePage. printToPdf ( arg__1 , arg__2 )
参数
  • arg__1 PyObject

  • arg__2 QPageLayout

PySide2.QtWebEngineWidgets.QWebEnginePage. printToPdf ( filePath [ , layout=QPageLayout(QPageSize(QPageSize.A4) , QPageLayout.Portrait , QMarginsF()) ] )
参数
  • filePath – unicode

  • layout QPageLayout

PySide2.QtWebEngineWidgets.QWebEnginePage. profile ( )
返回类型

QWebEngineProfile

返回页面所属 Web 引擎配置文件。

PySide2.QtWebEngineWidgets.QWebEnginePage. proxyAuthenticationRequired ( requestUrl , authenticator , proxyHost )
参数
  • requestUrl QUrl

  • authenticator QAuthenticator

  • proxyHost – unicode

PySide2.QtWebEngineWidgets.QWebEnginePage. recentlyAudible ( )
返回类型

bool

PySide2.QtWebEngineWidgets.QWebEnginePage. recentlyAudibleChanged ( recentlyAudible )
参数

recentlyAudible bool

PySide2.QtWebEngineWidgets.QWebEnginePage. renderProcessPid ( )
返回类型

qint64

PySide2.QtWebEngineWidgets.QWebEnginePage. renderProcessPidChanged ( pid )
参数

pid qint64

PySide2.QtWebEngineWidgets.QWebEnginePage. renderProcessTerminated ( terminationStatus , exitCode )
参数
PySide2.QtWebEngineWidgets.QWebEnginePage. replaceMisspelledWord ( replacement )
参数

replacement – unicode

替换当前拼写错误单词采用 replacement .

可以找到当前拼写错误单词在 misspelledWord() , and suggested replacements in spellCheckerSuggestions() .

另请参阅

contextMenuData()

PySide2.QtWebEngineWidgets.QWebEnginePage. requestedUrl ( )
返回类型

QUrl

PySide2.QtWebEngineWidgets.QWebEnginePage. runJavaScript ( arg__1 , arg__2 , arg__3 )
参数
  • arg__1 – unicode

  • arg__2 quint32

  • arg__3 PyObject

PySide2.QtWebEngineWidgets.QWebEnginePage. runJavaScript ( scriptSource )
参数

scriptSource – unicode

PySide2.QtWebEngineWidgets.QWebEnginePage. runJavaScript ( scriptSource , worldId )
参数
  • scriptSource – unicode

  • worldId quint32

PySide2.QtWebEngineWidgets.QWebEnginePage. save ( filePath [ , format=QWebEngineDownloadItem.MimeHtmlSaveFormat ] )
参数
  • filePath – unicode

  • format SavePageFormat

把当前加载网页保存到磁盘。

网页被保存到 filePath 以指定 format .

这是以下动作的捷径:

  • 触发保存 Web 动作。

  • 接受下一下载项,并设置指定文件路径和保存格式。

此函数为网页发出异步下载请求,并立即返回。

另请参阅

SavePageFormat

PySide2.QtWebEngineWidgets.QWebEnginePage. scripts ( )
返回类型

QWebEngineScriptCollection

返回被注入到页面中的脚本集合。

此外,页面还可能执行添加脚本透过 scripts() .

另请参阅

QWebEngineScriptCollection QWebEngineScript 脚本注入

PySide2.QtWebEngineWidgets.QWebEnginePage. scrollPosition ( )
返回类型

QPointF

PySide2.QtWebEngineWidgets.QWebEnginePage. scrollPositionChanged ( position )
参数

position QPointF

PySide2.QtWebEngineWidgets.QWebEnginePage. selectedText ( )
返回类型

unicode

PySide2.QtWebEngineWidgets.QWebEnginePage. selectionChanged ( )
PySide2.QtWebEngineWidgets.QWebEnginePage. setAudioMuted ( muted )
参数

muted bool

另请参阅

isAudioMuted()

PySide2.QtWebEngineWidgets.QWebEnginePage. setBackgroundColor ( color )
参数

color QColor

另请参阅

backgroundColor()

PySide2.QtWebEngineWidgets.QWebEnginePage. setContent ( data [ , mimeType="" [ , baseUrl=QUrl() ] ] )
参数
  • data QByteArray

  • mimeType – unicode

  • baseUrl QUrl

把网页内容设为 data 。若 mimeType 自变量为空,假定内容为 text/plain,charset=US-ASCII .

内容中引用的外部对象的定位相对于 baseUrl .

data 被立即加载;外部对象是异步加载的。

注意

此方法不会影响页面会话或全局历史。

警告

内容将被 % (百分号) 编码在凭借 IPC 被发送到渲染器之前。这可能增加其大小。% (百分号) 编码内容的最大大小 = 2 MB - 6 Bytes + MIME 类型字符串长度。

PySide2.QtWebEngineWidgets.QWebEnginePage. setDevToolsPage ( page )
参数

page QWebEnginePage

绑定 devToolsPage 成此页面的开发者工具。触发 devToolsPage 以采用开发者工具导航到内部 URL。

这如同调用 setInspectedPage() on devToolsPage with this 作为自变量。

PySide2.QtWebEngineWidgets.QWebEnginePage. setFeaturePermission ( securityOrigin , feature , policy )
参数

设置网站权限标识通过 securityOrigin 到使用 feature to policy .

注意

Call this method on the featurePermissionRequested() signal, as it is meant to serve pending feature requests only. Setting feature permissions ahead of a request has no effect.

PySide2.QtWebEngineWidgets.QWebEnginePage. setHtml ( html [ , baseUrl=QUrl() ] )
参数
  • html – unicode

  • baseUrl QUrl

Sets the content of this page to html . baseUrl is optional and used to resolve relative URLs in the document, such as referenced images or stylesheets.

html 被立即加载;外部对象是异步加载的。

If a script in the html runs longer than the default script timeout (currently 10 seconds), for example due to being blocked by a modal JavaScript alert dialog, this method will return as soon as possible after the timeout and any subsequent html will be loaded asynchronously.

When using this method, the web engine assumes that external resources, such as JavaScript programs or style sheets, are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified through the charset attribute of the HTML script tag. It is also possible for the encoding to be specified by the web server.

此方便函数相当于 setContent (html, “text/html”, baseUrl).

注意

此方法不会影响页面会话或全局历史。

警告

This function works only for HTML, for other mime types (such as XHTML and SVG) setContent() should be used instead.

警告

The content will be percent encoded before being sent to the renderer via IPC. This may increase its size. The maximum size of the percent encoded content is 2 megabytes minus 30 bytes.

PySide2.QtWebEngineWidgets.QWebEnginePage. setInspectedPage ( page )
参数

page QWebEnginePage

Navigates this page to an internal URL that is the developer tools of page .

这如同调用 setDevToolsPage() on page with this 作为自变量。

PySide2.QtWebEngineWidgets.QWebEnginePage. setUrl ( url )
参数

url QUrl

另请参阅

url()

PySide2.QtWebEngineWidgets.QWebEnginePage. setUrlRequestInterceptor ( interceptor )
参数

interceptor QWebEngineUrlRequestInterceptor

注册请求拦截器 interceptor 到拦截 URL 请求。

The page does not take ownership of the pointer. This interceptor is called after any interceptors on the profile, and unlike profile interceptors, only URL requests from this page are intercepted.

要取消请求拦截器设置,设置 nullptr .

另请参阅

QWebEngineUrlRequestInfo setUrlRequestInterceptor()

PySide2.QtWebEngineWidgets.QWebEnginePage. setView ( view )
参数

view QWidget

设置 view 关联网页。

另请参阅

view()

PySide2.QtWebEngineWidgets.QWebEnginePage. setVisible ( visible )
参数

visible bool

另请参阅

isVisible()

PySide2.QtWebEngineWidgets.QWebEnginePage. setWebChannel ( arg__1 )
参数

arg__1 QWebChannel

这是重载函数。

将此页面要使用的 Web 通道实例设为 channel 并将其安装在主 JavaScript 世界。

With this method the web channel can be accessed by web page content. If the content is not under your control and might be hostile, this could be a security issue and you should consider installing it in a private JavaScript world.

另请参阅

MainWorld

PySide2.QtWebEngineWidgets.QWebEnginePage. setWebChannel ( arg__1 , worldId )
参数
  • arg__1 QWebChannel

  • worldId uint

将此页面要使用的 Web 通道实例设为 channel and connects it to web engine’s transport using Chromium IPC messages. The transport is exposed in the JavaScript world worldId as qt.webChannelTransport , which should be used when using the Qt WebChannel JavaScript API .

注意

页面不拥有通道对象的所有权。

注意

Only one web channel can be installed per page, setting one even in another JavaScript world uninstalls any already installed web channel.

另请参阅

webChannel() ScriptWorldId

PySide2.QtWebEngineWidgets.QWebEnginePage. setZoomFactor ( factor )
参数

factor qreal

另请参阅

zoomFactor()

PySide2.QtWebEngineWidgets.QWebEnginePage. settings ( )
返回类型

QWebEngineSettings

Returns a pointer to the page’s settings object.

另请参阅

defaultSettings()

PySide2.QtWebEngineWidgets.QWebEnginePage. title ( )
返回类型

unicode

PySide2.QtWebEngineWidgets.QWebEnginePage. titleChanged ( title )
参数

title – unicode

PySide2.QtWebEngineWidgets.QWebEnginePage. toHtml ( arg__1 )
参数

arg__1 PyObject

PySide2.QtWebEngineWidgets.QWebEnginePage. toPlainText ( arg__1 )
参数

arg__1 PyObject

PySide2.QtWebEngineWidgets.QWebEnginePage. triggerAction ( action [ , checked=false ] )
参数

此函数可以被调用以触发指定 action 。它也会被调用通过 Qt WebEngine 若用户触发动作 (例如:透过上下文菜单项)。

action 是可复选动作,则 checked 指定动作是否被触发。

另请参阅

action()

PySide2.QtWebEngineWidgets.QWebEnginePage. url ( )
返回类型

QUrl

另请参阅

setUrl()

PySide2.QtWebEngineWidgets.QWebEnginePage. urlChanged ( url )
参数

url QUrl

PySide2.QtWebEngineWidgets.QWebEnginePage. view ( )
返回类型

QWidget

返回与网页关联的视图 Widget。

另请参阅

setView()

PySide2.QtWebEngineWidgets.QWebEnginePage. visibleChanged ( visible )
参数

visible bool

PySide2.QtWebEngineWidgets.QWebEnginePage. webChannel ( )
返回类型

QWebChannel

Returns a pointer to the web channel instance used by this page or a null pointer if none was set. This channel automatically uses the internal web engine transport mechanism over Chromium IPC that is exposed in the JavaScript context of this page as qt.webChannelTransport .

另请参阅

setWebChannel()

PySide2.QtWebEngineWidgets.QWebEnginePage. windowCloseRequested ( )
PySide2.QtWebEngineWidgets.QWebEnginePage. zoomFactor ( )
返回类型

qreal

另请参阅

setZoomFactor()