QWebEngineView — PyQt Documentation v5.15.7 (original) (raw)
PyQt5.QtWebEngineWidgets.QWebEngineView
Inherits from QWidget.
Description¶
The QWebEngineView class provides a widget that is used to view and edit web documents.
A web view is the main widget component of the Qt web browsing module. It can be used in various applications to display web content live from the Internet.
A web site can be loaded to a web view with the load() function. The GET method is always used to load URLs.
Like all Qt widgets, the show() function must be invoked in order to display the web view. The snippet below illustrates this:
QWebEngineView *view = new QWebEngineView(parent);
view->load(QUrl("http://qt-project.org/"));
view->show();
Alternatively, setUrl() can be used to load a web site. If you have the HTML content readily available, you can use setHtml() instead.
The loadStarted signal is emitted when the view begins loading and the loadProgress signal is emitted whenever an element of the web view completes loading, such as an embedded image or a script. The loadFinished signal is emitted when the view has been loaded completely. Its argument, either true
or false
, indicates whether loading was successful or failed.
The page() function returns a pointer to a web page object. A QWebEngineView contains a QWebEnginePage, which in turn allows access to the QWebEngineHistory in the page’s context.
The title of an HTML document can be accessed with the title() property. Additionally, a web site may 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.
The widget features a context menu that is tailored to the element at hand, and includes actions useful in a browser. For a custom context menu, or for embedding actions in a menu or toolbar, the individual actions are available via pageAction(). The web view maintains the state of the returned actions, but allows modification of action properties such as text or icon. The action semantics can also be triggered directly through triggerPageAction().
If you want to provide support for web sites that allow the user to open new windows, such as pop-up windows, you can subclass QWebEngineView and reimplement the createWindow() function.
Methods¶
__init__(parent: QWidget = None)
TODO
back()
TODO
closeEvent(QCloseEvent)
TODO
TODO
createWindow(WebWindowType) → QWebEngineView
TODO
dragEnterEvent(QDragEnterEvent)
TODO
dragLeaveEvent(QDragLeaveEvent)
TODO
dragMoveEvent(QDragMoveEvent)
TODO
dropEvent(QDropEvent)
TODO
event(QEvent) → bool
TODO
findText(str, options: Union[FindFlags, FindFlag] = QWebEnginePage.FindFlags(), resultCallback: Callable[[bool], None] = 0)
TODO
forward()
TODO
hasSelection() → bool
TODO
hideEvent(QHideEvent)
TODO
history() → QWebEngineHistory
TODO
icon() → QIcon
TODO
iconUrl() → QUrl
TODO
load(QUrl)
TODO
load(QWebEngineHttpRequest)
TODO
page() → QWebEnginePage
pageAction(WebAction) → QAction
TODO
reload()
TODO
selectedText() → str
TODO
setContent(Union[QByteArray, bytes, bytearray], mimeType: str = '', baseUrl: QUrl = QUrl())
TODO
setHtml(str, baseUrl: QUrl = QUrl())
TODO
setPage(QWebEnginePage)
settings() → QWebEngineSettings
TODO
setUrl(QUrl)
setZoomFactor(float)
showEvent(QShowEvent)
TODO
sizeHint() → QSize
TODO
stop()
TODO
title() → str
TODO
triggerPageAction(WebAction, checked: bool = False)
TODO
url() → QUrl
zoomFactor() → float
See also
Signals¶
iconChanged(QIcon)
TODO
iconUrlChanged(QUrl)
TODO
loadFinished(bool)
TODO
loadProgress(int)
TODO
loadStarted()
TODO
renderProcessTerminated(RenderProcessTerminationStatus, int)
TODO
selectionChanged()
TODO
titleChanged(str)
TODO
urlChanged(QUrl)
TODO