• PySide 模块
  • PySide.QtWebKit
  • 内容表

    上一话题

    QWebView

    下一话题

    PySide.phonon

    QWebFrame

    概要

    函数

    详细描述

    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> 元素。

    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() 代替。

    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.

    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 ) 若加载成功。

    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 使用 print() function. This function is marked as a slot and can be conveniently connected to PySide.QtGui.QPrintPreviewDialog ‘s PySide.QtGui.QPrintPreviewDialog.paintRequested() 信号。

    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:

    常量 描述
    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

    注意

    该枚举在 Qt 4.6 引入或被修改

    PySide.QtWebKit.QWebFrame. addToJavaScriptWindowObject ( name , object )
    参数:

    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. The interaction between C++ and JavaScript is explained in the documentation of the QtWebKit bridge .

    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() 信号。

    If Javascript is not enabled for this page, then this method does nothing.

    object will never be explicitly deleted by QtWebKit .

    PySide.QtWebKit.QWebFrame. addToJavaScriptWindowObject ( name , object , ownership )
    参数:
    PySide.QtWebKit.QWebFrame. baseUrl ( )
    返回类型: PySide.QtCore.QUrl

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

    PySide.QtWebKit.QWebFrame. childFrames ( )
    返回类型:

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

    PySide.QtWebKit.QWebFrame. contentsSize ( )
    返回类型: PySide.QtCore.QSize

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

    PySide.QtWebKit.QWebFrame. contentsSizeChanged ( size )
    参数: size PySide.QtCore.QSize
    PySide.QtWebKit.QWebFrame. documentElement ( )
    返回类型: 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 )
    参数: scriptSource – unicode
    返回类型: 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 )
    参数: selectorQuery – unicode
    返回类型: 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 )
    参数: selectorQuery – unicode
    返回类型: 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 ( )
    返回类型: unicode

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

    PySide.QtWebKit.QWebFrame. geometry ( )
    返回类型: PySide.QtCore.QRect

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

    PySide.QtWebKit.QWebFrame. hasFocus ( )
    返回类型: PySide.QtCore.bool

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

    PySide.QtWebKit.QWebFrame. hitTestContent ( pos )
    参数: pos PySide.QtCore.QPoint
    返回类型: 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 ( )
    返回类型: 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 )
    参数: url PySide.QtCore.QUrl

    加载 url into this frame.

    注意

    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() ] ] )
    参数:
    PySide.QtWebKit.QWebFrame. loadFinished ( ok )
    参数: ok PySide.QtCore.bool
    PySide.QtWebKit.QWebFrame. loadStarted ( )
    PySide.QtWebKit.QWebFrame. metaData ( )
    返回类型: 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.

    例如:

    <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
    “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 ( )
    返回类型: PySide.QtWebKit.QWebPage

    The web page that contains this frame.

    PySide.QtWebKit.QWebFrame. pageChanged ( )
    PySide.QtWebKit.QWebFrame. parentFrame ( )
    返回类型: 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 ( )
    返回类型: PySide.QtCore.QPoint

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

    PySide.QtWebKit.QWebFrame. print_ ( printer )
    参数: printer PySide.QtGui.QPrinter

    Prints the frame to the given printer .

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

    渲染 layer of the frame using painter clipping to clip .

    另请参阅

    print()

    PySide.QtWebKit.QWebFrame. render ( arg__1 , clip )
    参数:

    Render the frame into painter clipping to clip .

    PySide.QtWebKit.QWebFrame. render ( arg__1 )
    参数: arg__1 PySide.QtGui.QPainter

    Render the frame into painter .

    PySide.QtWebKit.QWebFrame. renderTreeDump ( )
    返回类型: unicode

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

    PySide.QtWebKit.QWebFrame. requestedUrl ( )
    返回类型: 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 )
    参数:
    • arg__1 PySide.QtCore.int
    • arg__2 PySide.QtCore.int

    Scrolls the frame dx 像素到右侧和 dy pixels downward. Both dx and dy 可能为负值。

    PySide.QtWebKit.QWebFrame. scrollBarGeometry ( orientation )
    参数: orientation PySide.QtCore.Qt.Orientation
    返回类型: PySide.QtCore.QRect
    PySide.QtWebKit.QWebFrame. scrollBarMaximum ( orientation )
    参数: orientation PySide.QtCore.Qt.Orientation
    返回类型: PySide.QtCore.int
    PySide.QtWebKit.QWebFrame. scrollBarMinimum ( orientation )
    参数: orientation PySide.QtCore.Qt.Orientation
    返回类型: PySide.QtCore.int
    PySide.QtWebKit.QWebFrame. scrollBarPolicy ( orientation )
    参数: orientation PySide.QtCore.Qt.Orientation
    返回类型: PySide.QtCore.Qt.ScrollBarPolicy
    PySide.QtWebKit.QWebFrame. scrollBarValue ( orientation )
    参数: orientation PySide.QtCore.Qt.Orientation
    返回类型: PySide.QtCore.int
    PySide.QtWebKit.QWebFrame. scrollPosition ( )
    返回类型: PySide.QtCore.QPoint

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

    PySide.QtWebKit.QWebFrame. scrollToAnchor ( anchor )
    参数: anchor – unicode

    Scrolls the frame to the given anchor name.

    PySide.QtWebKit.QWebFrame. securityOrigin ( )
    返回类型: PySide.QtWebKit.QWebSecurityOrigin

    Returns the frame's security origin.

    PySide.QtWebKit.QWebFrame. setContent ( data [ , mimeType="" [ , baseUrl=QUrl() ] ] )
    参数:

    Sets the content of this frame to the specified content data 。若 mimeType argument is empty it is currently assumed that the content is HTML but in future versions we may introduce auto-detection.

    内容中引用的外部对象的定位相对于 baseUrl .

    data 被立即加载;外部对象是异步加载的。

    注意

    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() ] )
    参数:

    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.

    html 被立即加载;外部对象是异步加载的。

    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.

    This is a convenience function equivalent to setContent(html, “text/html”, PySide.QtWebKit.QWebFrame.baseUrl() ).

    注意

    This method will not affect session or global history for the frame.

    警告

    This function works only for HTML, for other mime types (i.e. XHTML, SVG) PySide.QtWebKit.QWebFrame.setContent() should be used instead.

    PySide.QtWebKit.QWebFrame. setScrollBarPolicy ( orientation , policy )
    参数:
    • orientation PySide.QtCore.Qt.Orientation
    • policy PySide.QtCore.Qt.ScrollBarPolicy
    PySide.QtWebKit.QWebFrame. setScrollBarValue ( orientation , value )
    参数:
    • orientation PySide.QtCore.Qt.Orientation
    • value PySide.QtCore.int
    PySide.QtWebKit.QWebFrame. setScrollPosition ( pos )
    参数: pos PySide.QtCore.QPoint

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

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

    注意

    Setting this property also enables the ZoomTextOnly attribute in PySide.QtWebKit.QWebSettings .

    PySide.QtWebKit.QWebFrame. setUrl ( url )
    参数: url PySide.QtCore.QUrl

    This property holds the url of the frame currently viewed.

    设置此特性清零视图并加载 URL。

    默认情况下,此特性包含空的无效 URL。

    PySide.QtWebKit.QWebFrame. setZoomFactor ( factor )
    参数: factor PySide.QtCore.qreal

    This property holds the zoom factor for the frame.

    PySide.QtWebKit.QWebFrame. textSizeMultiplier ( )
    返回类型: 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 .

    注意

    Setting this property also enables the ZoomTextOnly attribute in PySide.QtWebKit.QWebSettings .

    PySide.QtWebKit.QWebFrame. title ( )
    返回类型: unicode

    This property holds the title of the frame as defined by the HTML <title> element.

    PySide.QtWebKit.QWebFrame. titleChanged ( title )
    参数: title – unicode
    PySide.QtWebKit.QWebFrame. toHtml ( )
    返回类型: unicode

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

    PySide.QtWebKit.QWebFrame. toPlainText ( )
    返回类型: unicode

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

    PySide.QtWebKit.QWebFrame. url ( )
    返回类型: PySide.QtCore.QUrl

    This property holds the url of the frame currently viewed.

    设置此特性清零视图并加载 URL。

    默认情况下,此特性包含空的无效 URL。

    PySide.QtWebKit.QWebFrame. urlChanged ( url )
    参数: url PySide.QtCore.QUrl
    PySide.QtWebKit.QWebFrame. zoomFactor ( )
    返回类型: PySide.QtCore.qreal

    This property holds the zoom factor for the frame.