QWebEngineFrame — PyQt Documentation v6.9.0 (original) (raw)

PyQt6.QtWebEngineCore.QWebEngineFrame

Description

The QWebEngineFrame class gives information about and control over a page frame.

A web engine frame represents a single frame within a web page, such as those created by <frame> or <iframe> HTML elements. An active QWebEnginePage has one or more frames arranged in a tree structure. The top-level frame, the root of this tree, can be accessed through the mainFrame() method, and children() provides a frame’s direct descendants.

A frame’s lifetime is, at most, as long as the QWebEnginePage object that produced it. However, frames may be created and deleted spontaneously and dynamically, for example through navigation and script execution. Because of this, many QWebEngineFrame methods return optional values, which will be std::nullopt if the frame no longer exists.

Methods

children() → list[QWebEngineFrame]

Returns a list of the frame’s children in an arbitrary order.

If the frame could not be found, returns an empty list.


__eq__(QWebEngineFrame) → bool

TODO


htmlName() → str

Returns the value of the frame’s name HTML attribute, or an empty string if it has none.

If the frame could not be found, returns a null QString.


isMainFrame() → bool

Returns true if this object represents the page’s main frame; false otherwise.


isValid() → bool

Returns true if this object represents an existing frame; false otherwise.

Once a frame is invalid, it never becomes valid again.


name() → str

Returns the frame name; that is, what would be returned by window.name in JavaScript.

If the frame could not be found, returns a null QString.


__ne__(QWebEngineFrame) → bool

TODO


printToPdf(Optional[str])

Renders the current content of the frame into a PDF document and saves it in the location specified in filePath. Printing uses a page size of A4, portrait layout, and includes the full range of pages.

This method issues an asynchronous request for printing the web page into a PDF and returns immediately. To be informed about the result of the request, connect to the pdfPrintingFinished signal.

Note: The Stop web action can be used to interrupt this asynchronous operation.

If a file already exists at the provided file path, it will be overwritten.


printToPdf(Callable[[Union[QByteArray, bytes, bytearray, memoryview]], None])

TODO


runJavaScript(Optional[str], worldId: int = 0)

TODO


runJavaScript(Optional[str], Callable[[Any], None])

TODO


runJavaScript(Optional[str], int, Callable[[Any], None])

TODO


size() → QSizeF

Returns the size of the frame within the viewport.

If the frame could not be found, returns QSizeF().


url() → QUrl

Returns the URL of the content currently loaded in this frame.

If the frame could not be found, returns an empty QUrl.