The PySide.QtWebKit.QWebFrame class represents a frame in a web page.
PySide.QtWebKit.QWebFrame represents a frame inside a web page. Each PySide.QtWebKit.QWebPage object contains at least one frame, the main frame, obtained using QWebPage.mainFrame() . Additional frames will be created for HTML <frame> or <iframe> elements.
A frame can be loaded using PySide.QtWebKit.QWebFrame.load() or PySide.QtWebKit.QWebFrame.setUrl() . Alternatively, if you have the HTML content readily available, you can use PySide.QtWebKit.QWebFrame.setHtml() instead.
The PySide.QtWebKit.QWebFrame.page() function returns a pointer to the web page object. See Elements of QWebView for an explanation of how web frames are related to a web page and web view.
The PySide.QtWebKit.QWebFrame class also offers methods to retrieve both the URL currently loaded by the frame (see PySide.QtWebKit.QWebFrame.url() ) as well as the URL originally requested to be loaded (see PySide.QtWebKit.QWebFrame.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 PySide.QtWebKit.QWebFrame.requestedUrl() also matches to the URL added to the frame history ( PySide.QtWebKit.QWebHistory ) if load is successful.
The title of an HTML frame can be accessed with the PySide.QtWebKit.QWebFrame.title() property. Additionally, a frame may also specify an icon, which can be accessed using the PySide.QtWebKit.QWebFrame.icon() property. If the title or the icon changes, the corresponding PySide.QtWebKit.QWebFrame.titleChanged() and PySide.QtWebKit.QWebFrame.iconChanged() signals will be emitted. The PySide.QtWebKit.QWebFrame.zoomFactor() property can be used to change the overall size of the content displayed in the frame.
PySide.QtWebKit.QWebFrame objects are created and controlled by the web page. You can connect to the web page’s PySide.QtWebKit.QWebPage.frameCreated() signal to be notified when a new frame is created.
There are multiple ways to programmatically examine the contents of a frame. The PySide.QtWebKit.QWebFrame.hitTestContent() function can be used to find elements by coordinate. For access to the underlying DOM tree, there is PySide.QtWebKit.QWebFrame.documentElement() , PySide.QtWebKit.QWebFrame.findAllElements() and PySide.QtWebKit.QWebFrame.findFirstElement() .
A PySide.QtWebKit.QWebFrame can be printed onto a PySide.QtGui.QPrinter using the print() function. This function is marked as a slot and can be conveniently connected to PySide.QtGui.QPrintPreviewDialog ‘s PySide.QtGui.QPrintPreviewDialog.paintRequested() signal.
See also
This enum describes the layers available for rendering using PySide.QtWebKit.QWebFrame.render() . The layers can be OR-ed together from the following list:
Constant | Description |
---|---|
QWebFrame.ContentsLayer | The web content of the frame |
QWebFrame.ScrollBarLayer | The scrollbars of the frame |
QWebFrame.PanIconLayer | The icon used when panning the frame |
QWebFrame.AllLayers | Includes all the above layers |
Note
This enum was introduced or modified in Qt 4.6
Parameters: |
|
---|
Make object available under name from within the frame’s JavaScript context. The object will be inserted as a child of the frame’s window object.
Qt properties will be exposed as JavaScript properties and slots as JavaScript methods.
If you want to ensure that your QObjects remain accessible after loading a new URL, you should add them in a slot connected to the PySide.QtWebKit.QWebFrame.javaScriptWindowObjectCleared() signal.
If Javascript is not enabled for this page, then this method does nothing.
The object will never be explicitly deleted by QtWebKit .
Parameters: |
|
---|
Return type: | PySide.QtCore.QUrl |
---|
This property holds the base URL of the frame, can be used to resolve relative URLs.
Return type: |
---|
Returns a list of all frames that are direct children of this frame.
Return type: | PySide.QtCore.QSize |
---|
This property holds the size of the contents in this frame.
Parameters: | size – PySide.QtCore.QSize |
---|
Return type: | PySide.QtWebKit.QWebElement |
---|
Returns the document element of this frame.
The document element provides access to the entire structured content of the frame.
Parameters: | scriptSource – unicode |
---|---|
Return type: | object |
Evaluates the JavaScript defined by scriptSource using this frame as context and returns the result of the last executed statement.
Parameters: | selectorQuery – unicode |
---|---|
Return type: | PySide.QtWebKit.QWebElementCollection |
Returns a new list of elements matching the given CSS selector selectorQuery . If there are no matching elements, an empty list is returned.
Standard CSS2 selector syntax is used for the query.
See also
Parameters: | selectorQuery – unicode |
---|---|
Return type: | PySide.QtWebKit.QWebElement |
Returns the first element in the frame’s document that matches the given CSS selector selectorQuery . If there is no matching element, a null element is returned.
Standard CSS2 selector syntax is used for the query.
See also
Return type: | unicode |
---|
The name of this frame as defined by the parent frame.
Return type: | PySide.QtCore.QRect |
---|
Return the geometry of the frame relative to it’s parent frame.
Return type: | PySide.QtCore.bool |
---|
Returns true if this frame has keyboard input focus; otherwise, returns false.
Parameters: | pos – PySide.QtCore.QPoint |
---|---|
Return type: | PySide.QtWebKit.QWebHitTestResult |
Performs a hit test on the frame contents at the given position pos and returns the hit test result.
Return type: | PySide.QtGui.QIcon |
---|
This property holds the icon associated with this frame.
Parameters: | url – PySide.QtCore.QUrl |
---|
Loads url into this frame.
Note
The view remains the same until enough data has arrived to display the new url .
Parameters: |
|
---|
Parameters: | ok – PySide.QtCore.bool |
---|
Return type: | PyObject |
---|
Returns the meta data in this frame as a QMultiMap
The meta data consists of the name and content attributes of the of the <meta> tags in the HTML document.
For example:
<html>
<head>
<meta name="description" content="This document is a tutorial about Qt development">
<meta name="keywords" content="Qt, WebKit, Programming">
</head>
...
</html>
Given the above HTML code the PySide.QtWebKit.QWebFrame.metaData() function will return a map with two entries:
Key | Value |
“description” | “This document is a tutorial about Qt development” |
“keywords” | “Qt, WebKit, Programming” |
This function returns a multi map to support multiple meta tags with the same attribute name.
Return type: | PySide.QtWebKit.QWebPage |
---|
The web page that contains this frame.
Return type: | PySide.QtWebKit.QWebFrame |
---|
Returns the parent frame of this frame, or 0 if the frame is the web pages main frame.
This is equivalent to qobject_cast< PySide.QtWebKit.QWebFrame *>(frame-> PySide.QtCore.QObject.parent() ).
Return type: | PySide.QtCore.QPoint |
---|
Returns the position of the frame relative to it’s parent frame.
Parameters: | printer – PySide.QtGui.QPrinter |
---|
Prints the frame to the given printer .
See also
Parameters: |
|
---|
Render the layer of the frame using painter clipping to clip .
See also
print()
Parameters: |
|
---|
Render the frame into painter clipping to clip .
Parameters: | arg__1 – PySide.QtGui.QPainter |
---|
Render the frame into painter .
Return type: | unicode |
---|
Returns a dump of the rendering tree. This is mainly useful for debugging html.
Return type: | PySide.QtCore.QUrl |
---|
The URL requested to loaded by the frame currently viewed. The URL may differ from the one returned by PySide.QtWebKit.QWebFrame.url() if a DNS resolution or a redirection occurs.
Parameters: |
|
---|
Scrolls the frame dx pixels to the right and dy pixels downward. Both dx and dy may be negative.
See also
Parameters: | orientation – PySide.QtCore.Qt.Orientation |
---|---|
Return type: | PySide.QtCore.QRect |
Parameters: | orientation – PySide.QtCore.Qt.Orientation |
---|---|
Return type: | PySide.QtCore.int |
Parameters: | orientation – PySide.QtCore.Qt.Orientation |
---|---|
Return type: | PySide.QtCore.int |
Parameters: | orientation – PySide.QtCore.Qt.Orientation |
---|---|
Return type: | PySide.QtCore.Qt.ScrollBarPolicy |
Parameters: | orientation – PySide.QtCore.Qt.Orientation |
---|---|
Return type: | PySide.QtCore.int |
Return type: | PySide.QtCore.QPoint |
---|
This property holds the position the frame is currently scrolled to..
Parameters: | anchor – unicode |
---|
Scrolls the frame to the given anchor name.
Return type: | PySide.QtWebKit.QWebSecurityOrigin |
---|
Returns the frame’s security origin.
Parameters: |
|
---|
Sets the content of this frame to the specified content data . If the mimeType argument is empty it is currently assumed that the content is HTML but in future versions we may introduce auto-detection.
External objects referenced in the content are located relative to baseUrl .
The data is loaded immediately; external objects are loaded asynchronously.
Note
This method will not affect session or global history for the frame.
Gives keyboard input focus to this frame.
See also
Parameters: |
|
---|
Sets the content of this frame to html . baseUrl is optional and used to resolve relative URLs in the document, such as referenced images or stylesheets.
The html is loaded immediately; external objects are loaded asynchronously.
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 WebKit 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 web server.
Note
This method will not affect session or global history for the frame.
Parameters: |
|
---|
Parameters: |
|
---|
Parameters: | pos – PySide.QtCore.QPoint |
---|
This property holds the position the frame is currently scrolled to..
Parameters: | factor – PySide.QtCore.qreal |
---|
This property holds the scaling factor for all text in the frame.
Use setZoomFactor instead, in combination with the ZoomTextOnly attribute in PySide.QtWebKit.QWebSettings .
Note
Setting this property also enables the ZoomTextOnly attribute in PySide.QtWebKit.QWebSettings .
Parameters: | url – PySide.QtCore.QUrl |
---|
This property holds the url of the frame currently viewed.
Setting this property clears the view and loads the URL.
By default, this property contains an empty, invalid URL.
Parameters: | factor – PySide.QtCore.qreal |
---|
This property holds the zoom factor for the frame.
Return type: | PySide.QtCore.qreal |
---|
This property holds the scaling factor for all text in the frame.
Use setZoomFactor instead, in combination with the ZoomTextOnly attribute in PySide.QtWebKit.QWebSettings .
Note
Setting this property also enables the ZoomTextOnly attribute in PySide.QtWebKit.QWebSettings .
Return type: | unicode |
---|
This property holds the title of the frame as defined by the HTML <title> element.
Parameters: | title – unicode |
---|
Return type: | unicode |
---|
Returns the frame’s content as HTML, enclosed in HTML and BODY tags.
Return type: | unicode |
---|
Returns the content of this frame converted to plain text, completely stripped of all HTML formatting.
See also
Return type: | PySide.QtCore.QUrl |
---|
This property holds the url of the frame currently viewed.
Setting this property clears the view and loads the URL.
By default, this property contains an empty, invalid URL.
Parameters: | url – PySide.QtCore.QUrl |
---|
Return type: | PySide.QtCore.qreal |
---|
This property holds the zoom factor for the frame.