Table Of Contents

Previous topic

QWebInspector

Next topic

QWebView

QWebFrame

Inheritance diagram of QWebFrame

Synopsis

Functions

Slots

Signals

Detailed Description

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.

PySide.QtWebKit.QWebFrame.RenderLayer

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

PySide.QtWebKit.QWebFrame.addToJavaScriptWindowObject(name, object)
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 .

PySide.QtWebKit.QWebFrame.addToJavaScriptWindowObject(name, object, ownership)
Parameters:
  • name – unicode
  • objectPySide.QtCore.QObject
  • ownershipPySide.QtScript.QScriptEngine.ValueOwnership
PySide.QtWebKit.QWebFrame.baseUrl()
Return type:PySide.QtCore.QUrl

This property holds the base URL of the frame, can be used to resolve relative URLs.

PySide.QtWebKit.QWebFrame.childFrames()
Return type:

Returns a list of all frames that are direct children of this frame.

PySide.QtWebKit.QWebFrame.contentsSize()
Return type:PySide.QtCore.QSize

This property holds the size of the contents in this frame.

PySide.QtWebKit.QWebFrame.contentsSizeChanged(size)
Parameters:sizePySide.QtCore.QSize
PySide.QtWebKit.QWebFrame.documentElement()
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.

PySide.QtWebKit.QWebFrame.evaluateJavaScript(scriptSource)
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.

PySide.QtWebKit.QWebFrame.findAllElements(selectorQuery)
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.

PySide.QtWebKit.QWebFrame.findFirstElement(selectorQuery)
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.

PySide.QtWebKit.QWebFrame.frameName()
Return type:unicode

The name of this frame as defined by the parent frame.

PySide.QtWebKit.QWebFrame.geometry()
Return type:PySide.QtCore.QRect

Return the geometry of the frame relative to it’s parent frame.

PySide.QtWebKit.QWebFrame.hasFocus()
Return type:PySide.QtCore.bool

Returns true if this frame has keyboard input focus; otherwise, returns false.

PySide.QtWebKit.QWebFrame.hitTestContent(pos)
Parameters:posPySide.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.

PySide.QtWebKit.QWebFrame.icon()
Return type:PySide.QtGui.QIcon

This property holds the icon associated with this frame.

PySide.QtWebKit.QWebFrame.iconChanged()
PySide.QtWebKit.QWebFrame.initialLayoutCompleted()
PySide.QtWebKit.QWebFrame.javaScriptWindowObjectCleared()
PySide.QtWebKit.QWebFrame.load(url)
Parameters:urlPySide.QtCore.QUrl

Loads url into this frame.

Note

The view remains the same until enough data has arrived to display the new url .

PySide.QtWebKit.QWebFrame.load(request[, operation=QNetworkAccessManager.GetOperation[, body=QByteArray()]])
Parameters:
PySide.QtWebKit.QWebFrame.loadFinished(ok)
Parameters:okPySide.QtCore.bool
PySide.QtWebKit.QWebFrame.loadStarted()
PySide.QtWebKit.QWebFrame.metaData()
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.

PySide.QtWebKit.QWebFrame.page()
Return type:PySide.QtWebKit.QWebPage

The web page that contains this frame.

PySide.QtWebKit.QWebFrame.pageChanged()
PySide.QtWebKit.QWebFrame.parentFrame()
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() ).

PySide.QtWebKit.QWebFrame.pos()
Return type:PySide.QtCore.QPoint

Returns the position of the frame relative to it’s parent frame.

PySide.QtWebKit.QWebFrame.print_(printer)
Parameters:printerPySide.QtGui.QPrinter

Prints the frame to the given printer .

PySide.QtWebKit.QWebFrame.provisionalLoad()
PySide.QtWebKit.QWebFrame.render(arg__1, layer[, clip=QRegion()])
Parameters:

Render the layer of the frame using painter clipping to clip .

See also

print()

PySide.QtWebKit.QWebFrame.render(arg__1, clip)
Parameters:

Render the frame into painter clipping to clip .

PySide.QtWebKit.QWebFrame.render(arg__1)
Parameters:arg__1PySide.QtGui.QPainter

Render the frame into painter .

PySide.QtWebKit.QWebFrame.renderTreeDump()
Return type:unicode

Returns a dump of the rendering tree. This is mainly useful for debugging html.

PySide.QtWebKit.QWebFrame.requestedUrl()
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.

PySide.QtWebKit.QWebFrame.scroll(arg__1, arg__2)
Parameters:
  • arg__1PySide.QtCore.int
  • arg__2PySide.QtCore.int

Scrolls the frame dx pixels to the right and dy pixels downward. Both dx and dy may be negative.

PySide.QtWebKit.QWebFrame.scrollBarGeometry(orientation)
Parameters:orientationPySide.QtCore.Qt.Orientation
Return type:PySide.QtCore.QRect
PySide.QtWebKit.QWebFrame.scrollBarMaximum(orientation)
Parameters:orientationPySide.QtCore.Qt.Orientation
Return type:PySide.QtCore.int
PySide.QtWebKit.QWebFrame.scrollBarMinimum(orientation)
Parameters:orientationPySide.QtCore.Qt.Orientation
Return type:PySide.QtCore.int
PySide.QtWebKit.QWebFrame.scrollBarPolicy(orientation)
Parameters:orientationPySide.QtCore.Qt.Orientation
Return type:PySide.QtCore.Qt.ScrollBarPolicy
PySide.QtWebKit.QWebFrame.scrollBarValue(orientation)
Parameters:orientationPySide.QtCore.Qt.Orientation
Return type:PySide.QtCore.int
PySide.QtWebKit.QWebFrame.scrollPosition()
Return type:PySide.QtCore.QPoint

This property holds the position the frame is currently scrolled to..

PySide.QtWebKit.QWebFrame.scrollToAnchor(anchor)
Parameters:anchor – unicode

Scrolls the frame to the given anchor name.

PySide.QtWebKit.QWebFrame.securityOrigin()
Return type:PySide.QtWebKit.QWebSecurityOrigin

Returns the frame’s security origin.

PySide.QtWebKit.QWebFrame.setContent(data[, mimeType=""[, baseUrl=QUrl()]])
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.

PySide.QtWebKit.QWebFrame.setFocus()

Gives keyboard input focus to this frame.

PySide.QtWebKit.QWebFrame.setHtml(html[, baseUrl=QUrl()])
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.

PySide.QtWebKit.QWebFrame.setScrollBarPolicy(orientation, policy)
Parameters:
  • orientationPySide.QtCore.Qt.Orientation
  • policyPySide.QtCore.Qt.ScrollBarPolicy
PySide.QtWebKit.QWebFrame.setScrollBarValue(orientation, value)
Parameters:
  • orientationPySide.QtCore.Qt.Orientation
  • valuePySide.QtCore.int
PySide.QtWebKit.QWebFrame.setScrollPosition(pos)
Parameters:posPySide.QtCore.QPoint

This property holds the position the frame is currently scrolled to..

PySide.QtWebKit.QWebFrame.setTextSizeMultiplier(factor)
Parameters:factorPySide.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 .

PySide.QtWebKit.QWebFrame.setUrl(url)
Parameters:urlPySide.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.

PySide.QtWebKit.QWebFrame.setZoomFactor(factor)
Parameters:factorPySide.QtCore.qreal

This property holds the zoom factor for the frame.

PySide.QtWebKit.QWebFrame.textSizeMultiplier()
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 .

PySide.QtWebKit.QWebFrame.title()
Return type:unicode

This property holds the title of the frame as defined by the HTML &lt;title&gt; element.

PySide.QtWebKit.QWebFrame.titleChanged(title)
Parameters:title – unicode
PySide.QtWebKit.QWebFrame.toHtml()
Return type:unicode

Returns the frame’s content as HTML, enclosed in HTML and BODY tags.

PySide.QtWebKit.QWebFrame.toPlainText()
Return type:unicode

Returns the content of this frame converted to plain text, completely stripped of all HTML formatting.

PySide.QtWebKit.QWebFrame.url()
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.

PySide.QtWebKit.QWebFrame.urlChanged(url)
Parameters:urlPySide.QtCore.QUrl
PySide.QtWebKit.QWebFrame.zoomFactor()
Return type:PySide.QtCore.qreal

This property holds the zoom factor for the frame.