PySide6.QtWebView.QWebView¶
- class QWebView¶
The
QWebViewclass provides a window that is used to view web content.Details
A web view is a window for displaying web content that is implemented using native APIs on the platforms where they are available. Therefore, it does not necessarily require including a full web browser stack as part of the application.
A web site can be loaded to a web view with the
setUrl()function.Alternatively, if you have the HTML content readily available, you can use setHtml() instead.
The
loadingChanged()signal is emitted when the view begins loading and when the view has been loaded completely. Its argument QWebViewLoadRequest object indicates whether loading was successful or failed.The title of an HTML document can be accessed with the
title()property.Added in version 6.11.
Synopsis¶
Properties¶
httpUserAgentStringᅟ- User agent in use. The user-agent string sent with HTTP to identify the browsersettingsᅟ- Settings object for the QWebView. The settings for a web viewtitleᅟ- Of the currently loaded web pageurlᅟ- URL of the web page currently viewed
Methods¶
def
__init__()def
canGoBack()def
canGoForward()def
isLoading()def
loadProgress()def
runJavaScript()def
settings()def
url()
Slots¶
def
deleteCookie()def
goBack()def
goForward()def
loadHtml()def
reload()def
setCookie()def
setUrl()def
stop()
Signals¶
def
cookieAdded()def
cookieRemoved()def
loadingChanged()def
titleChanged()def
urlChanged()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Note
Properties can be used directly when
from __feature__ import true_propertyis used or via accessor functions otherwise.- property httpUserAgentStringᅟ: str¶
This property holds The user agent in use. The user-agent string sent with HTTP to identify the browser..
- Access functions:
- property loadProgressᅟ: int¶
The current load progress of the web content, represented as an integer between 0 and 100.
- Access functions:
- property loadingᅟ: bool¶
Holds
trueif the WebView is currently in the process of loading new content,falseotherwise.- Access functions:
Signal
loadingChanged()
- property settingsᅟ: QWebViewSettings¶
This property holds Settings object for the
QWebView. The settings for a web view..See also
- Access functions:
- property titleᅟ: str¶
This property holds The title of the currently loaded web page..
The title of the page as defined by the HTML
<title>element.See also
- Access functions:
Signal
titleChanged()
This property holds The URL of the web page currently viewed..
Setting this property clears the view and loads the URL. By default, this property contains an empty, invalid URL. URLs that originate from user input should be parsed with QUrl::fromUserInput().
- Access functions:
Signal
urlChanged()
- __init__(parent)
- Parameters:
parent –
QWindow
- canGoBack()¶
- Return type:
bool
Returns
trueif it’s currently possible to navigate back in the web history.- canGoForward()¶
- Return type:
bool
Returns
trueif it’s currently possible to navigate forward in the web history.- cookieAdded(domain, name)¶
- Parameters:
domain – str
name – str
- cookieRemoved(domain, name)¶
- Parameters:
domain – str
name – str
- deleteAllCookies()¶
Deletes all the cookies.
- deleteCookie(domain, name)¶
- Parameters:
domain – str
name – str
- goBack()¶
Navigates back in the web history.
- goForward()¶
Navigates forward in the web history.
- httpUserAgentString()¶
- Return type:
str
See also
Getter of property
httpUserAgentStringᅟ.- httpUserAgentStringChanged(userAgent)¶
- Parameters:
userAgent – str
This signal is emitted whenever the
userAgentof the view changes.See also
httpUserAgent()Notification signal of property
httpUserAgentStringᅟ.- isLoading()¶
- Return type:
bool
Getter of property
loadingᅟ.Loads the specified
htmlcontent to the web view.This method offers a lower-level alternative to the
urlproperty, which references HTML pages via URL.External objects such as stylesheets or images referenced in the HTML document should be located relative to
baseUrl. For example, ifhtmlis retrieved fromhttp://www.example.com/documents/overview.html, which is the base URL, then an image referenced with the relative URLdiagram.png, should be athttp://www.example.com/documents/diagram.png.Note
The
QWebViewdoes not support loading content through the Qt Resource system.- loadProgress()¶
- Return type:
int
Getter of property
loadProgressᅟ.- loadProgressChanged(loadProgress)¶
- Parameters:
loadProgress – int
This signal is continuously emitted during the loading of a web page. The
loadProgressparameter is a value between 0 and 100, indicating what percentage of the web page has been loaded. The intended use for this is to display a progress bar to the user.Note
Some backends do not support fractional load progress changes, and will only emit this signal at the start and end of a load, with values of 0 and 100, respecively.
See also
Notification signal of property
loadProgressᅟ.- loadingChanged(loadingInfo)¶
- Parameters:
loadingInfo –
QWebViewLoadingInfo
This signal is emitted when the state of loading the web content changes. By handling this signal it’s possible, for example, to react to page load errors.
The
loadingInfoparameter holds the url and status of the request, as well as an errorString containing an error message for a failed request.See also
Notification signal of property
loadingᅟ.- reload()¶
Reloads the current
url.- runJavaScript(scriptSource, resultCallback)¶
- Parameters:
scriptSource – str
resultCallback –
PyCallable
- setCookie(domain, name, value)¶
- Parameters:
domain – str
name – str
value – str
- setHttpUserAgentString(httpUserAgent)¶
- Parameters:
httpUserAgent – str
See also
Setter of property
httpUserAgentStringᅟ.Setter of property
urlᅟ.- settings()¶
- Return type:
Getter of property
settingsᅟ.- stop()¶
Stops loading the current
url.- titleChanged(title)¶
- Parameters:
title – str
This signal is emitted whenever the
titleof the view changes.See also
title()Notification signal of property
titleᅟ.Getter of property
urlᅟ.This signal is emitted whenever the
urlof the view changes.See also
Notification signal of property
urlᅟ.