Class: QgsWebEnginePage¶
A wrapper around the QWebEnginePage class, adding extra functionality.
Warning
This class is only available on QGIS builds with WebEngine support enabled.
Added in version 3.36.
List of all members, including inherited members
Class Hierarchy¶
Base classes¶
Methods
Returns the size of the page document, in pixels. |
|
Renders the web page contents to a painter. |
|
Sets the content of the web page to data. |
|
Sets the content of this page to html. |
|
Sets the url of the web page to be displayed. |
Signals
This signal is emitted when the page finishes loading content. |
|
This signal is emitted when the global progress status changes. |
|
This signal is emitted when the page starts loading content. |
- class qgis.core.QgsWebEnginePage[source]¶
Bases:
QObject- __init__(parent: QObject | None = None)
Constructor for QgsWebEnginePage, with the specified
parentwidget.- Parameters:
parent (Optional[QObject] = None)
- documentSize(self) QSize[source]¶
Returns the size of the page document, in pixels.
Warning
If the page content was NOT loaded using a blocking method, then this method involves running the event loop on the current thread. Take care when calling from the main thread as incorrect use will result in crashes.
- Return type:
QSize
- signal loadFinished(ok: bool)[source]¶
This signal is emitted when the page finishes loading content.
This signal is independent of script execution or page rendering.
okwill indicate whether the load was successful or any error occurred.- Parameters:
ok (bool)
- signal loadProgress(progress: int)[source]¶
This signal is emitted when the global
progressstatus changes.The current value is provided by
progressand scales from 0 to 100. It accumulates changes from all the child frames.- Parameters:
progress (int)
- render(self, painter: QPainter | None, painterRect: QRectF) bool[source]¶
Renders the web page contents to a
painter. Content will be rendered as vector objects.The
painterRectargument specifies the target rectangle for the page inpaintercoordinates.Warning
This method involves running the event loop on the current thread. Take care when calling from the main thread as incorrect use will result in crashes.
Warning
This method requires a QGIS build with PDF4Qt library support.
- Return type:
bool
- Returns:
Trueif rendering was successful- Raises:
QgsNotSupportedException – on QGIS builds without PDF4Qt library support.
- Parameters:
painter (Optional[QPainter])
painterRect (QRectF)
- setContent(self, data: QByteArray | bytes | bytearray | memoryview, mimeType: str | None = '', baseUrl: QUrl = QUrl(), blocking: bool = False) bool[source]¶
Sets the content of the web page to
data. If themimeTypeargument is empty, it is assumed that the content is text/plain,charset=US-ASCIIThe
baseUrlis optional and used to resolve relative URLs in the document, such as referenced images or stylesheets.If
blockingisTruethen the call will block while the HTML is loaded. Otherwise the html is loaded immediately; external objects are loaded asynchronously.Warning
Setting
blockingtoTrueinvolves running the event loop on the current thread. Take care when calling from the main thread as incorrect use will result in crashes.
- setHtml(self, html: str | None, baseUrl: QUrl = QUrl(), blocking: bool = False) bool[source]¶
Sets the content of this page to
html.The
baseUrlis optional and used to resolve relative URLs in the document, such as referenced images or stylesheets.If
blockingisTruethen the call will block while the HTML is loaded. Otherwise the html is loaded immediately; external objects are loaded asynchronously.Note
This function works only for HTML, for other mime types (such as XHTML and SVG)
setContent()should be used instead.Warning
Setting
blockingtoTrueinvolves running the event loop on the current thread. Take care when calling from the main thread as incorrect use will result in crashes.- Return type:
bool
- Returns:
Trueif loading was successful- Parameters:
html (Optional[str])
baseUrl (QUrl = QUrl())
blocking (bool = False)
- setUrl(self, url: QUrl, blocking: bool = False) bool[source]¶
Sets the
urlof the web page to be displayed.Setting this property clears the page and loads the URL.
If
blockingisTruethen the call will block while the HTML is loaded. Otherwise the html is loaded immediately; external objects are loaded asynchronously.Warning
Setting
blockingtoTrueinvolves running the event loop on the current thread. Take care when calling from the main thread as incorrect use will result in crashes.- Return type:
bool
- Returns:
Trueif loading was successful- Parameters:
url (QUrl)
blocking (bool = False)