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

    上一话题

    QSvgGenerator

    下一话题

    QGraphicsSvgItem

    QSvgRenderer

    概要

    信号

    详细描述

    PySide.QtSvg.QSvgRenderer class is used to draw the contents of SVG files onto paint devices.

    使用 PySide.QtSvg.QSvgRenderer , Scalable Vector Graphics (SVG) can be rendered onto any PySide.QtGui.QPaintDevice subclass, including PySide.QtGui.QWidget , PySide.QtGui.QImage ,和 PySide.QtOpenGL.QGLWidget .

    PySide.QtSvg.QSvgRenderer provides an API that supports basic features of SVG rendering, such as loading and rendering of static drawings, and more interactive features like animation. Since the rendering is performed using PySide.QtGui.QPainter , SVG drawings can be rendered on any subclass of PySide.QtGui.QPaintDevice .

    SVG drawings are either loaded when an PySide.QtSvg.QSvgRenderer is constructed, or loaded later using the PySide.QtSvg.QSvgRenderer.load() functions. Data is either supplied directly as serialized XML, or indirectly using a file name. If a valid file has been loaded, either when the renderer is constructed or at some later time, PySide.QtSvg.QSvgRenderer.isValid() returns true; otherwise it returns false. PySide.QtSvg.QSvgRenderer provides the PySide.QtSvg.QSvgRenderer.render() slot to render the current document, or the current frame of an animated document, using a given painter.

    PySide.QtSvg.QSvgRenderer.defaultSize() function provides information about the amount of space that is required to render the currently loaded SVG file. This is useful for paint devices, such as PySide.QtGui.QWidget , that often need to supply a size hint to their parent layout. The default size of a drawing may differ from its visible area, found using the PySide.QtSvg.QSvgRenderer.viewBox() 特性。

    Animated SVG drawings are supported, and can be controlled with a simple collection of functions and properties:

    Finally, the PySide.QtSvg.QSvgRenderer class provides the PySide.QtSvg.QSvgRenderer.repaintNeeded() signal which is emitted whenever the rendering of the document needs to be updated.

    另请参阅

    PySide.QtSvg.QSvgWidget QtSvg Module SVG Viewer Example PySide.QtGui.QPicture

    class PySide.QtSvg. QSvgRenderer ( [ parent=None ] )
    class PySide.QtSvg. QSvgRenderer ( contents [ , parent=None ] )
    class PySide.QtSvg. QSvgRenderer ( contents [ , parent=None ] )
    class PySide.QtSvg. QSvgRenderer ( filename [ , parent=None ] )
    参数:

    Constructs a new renderer with the given parent .

    Constructs a new renderer with the given parent and loads the SVG data using the stream reader specified by contents .

    Constructs a new renderer with the given parent and loads the SVG data from the byte array specified by contents .

    Constructs a new renderer with the given parent and loads the contents of the SVG file with the specified filename .

    PySide.QtSvg.QSvgRenderer. animated ( )
    返回类型: PySide.QtCore.bool

    Returns true if the current document contains animated elements; otherwise returns false.

    PySide.QtSvg.QSvgRenderer. animationDuration ( )
    返回类型: PySide.QtCore.int

    Returns the number of frames in the animation, or 0 if the current document is not animated.

    PySide.QtSvg.QSvgRenderer. boundsOnElement ( id )
    参数: id – unicode
    返回类型: PySide.QtCore.QRectF

    Returns bounding rectangle of the item with the given id . The transformation matrix of parent elements is not affecting the bounds of the element.

    PySide.QtSvg.QSvgRenderer. currentFrame ( )
    返回类型: PySide.QtCore.int

    This property holds the current frame of the document's animation, or 0 if the document is not animated.

    PySide.QtSvg.QSvgRenderer. defaultSize ( )
    返回类型: PySide.QtCore.QSize

    Returns the default size of the document contents.

    PySide.QtSvg.QSvgRenderer. elementExists ( id )
    参数: id – unicode
    返回类型: PySide.QtCore.bool

    Returns true if the element with the given id exists in the currently parsed SVG file and is a renderable element.

    Note: this method returns true only for elements that can be rendered. Which implies that elements that are considered part of the fill/stroke style properties, e.g. radialGradients even tough marked with “id” attributes will not be found by this method.

    PySide.QtSvg.QSvgRenderer. framesPerSecond ( )
    返回类型: PySide.QtCore.int

    This property holds the number of frames per second to be shown.

    The number of frames per second is 0 if the current document is not animated.

    PySide.QtSvg.QSvgRenderer. isValid ( )
    返回类型: PySide.QtCore.bool

    Returns true if there is a valid current document; otherwise returns false.

    PySide.QtSvg.QSvgRenderer. load ( contents )
    参数: contents PySide.QtCore.QByteArray
    返回类型: PySide.QtCore.bool

    Loads the specified SVG format contents , returning true if the content was successfully parsed; otherwise returns false.

    PySide.QtSvg.QSvgRenderer. load ( filename )
    参数: filename – unicode
    返回类型: PySide.QtCore.bool

    Loads the SVG file specified by filename , returning true if the content was successfully parsed; otherwise returns false.

    PySide.QtSvg.QSvgRenderer. load ( contents )
    参数: contents PySide.QtCore.QXmlStreamReader
    返回类型: PySide.QtCore.bool

    Loads the specified SVG in contents , returning true if the content was successfully parsed; otherwise returns false.

    The reader will be used from where it currently is positioned. If contents is null , behavior is undefined.

    PySide.QtSvg.QSvgRenderer. matrixForElement ( id )
    参数: id – unicode
    返回类型: PySide.QtGui.QMatrix

    Returns the transformation matrix for the element with the given id . The matrix is a product of the transformation of the element's parents. The transformation of the element itself is not included.

    To find the bounding rectangle of the element in logical coordinates, you can apply the matrix on the rectangle returned from PySide.QtSvg.QSvgRenderer.boundsOnElement() .

    PySide.QtSvg.QSvgRenderer. render ( p , bounds )
    参数:

    Renders the current document, or the current frame of an animated document, using the given painter on the specified bounds within the painter. If the bounding rectangle is not specified the SVG file is mapped to the whole paint device.

    PySide.QtSvg.QSvgRenderer. render ( p , elementId [ , bounds=QRectF() ] )
    参数:

    Renders the given element with elementId using the given painter on the specified bounds . If the bounding rectangle is not specified the SVG element is mapped to the whole paint device.

    PySide.QtSvg.QSvgRenderer. render ( p )
    参数: p PySide.QtGui.QPainter

    Renders the current document, or the current frame of an animated document, using the given painter .

    PySide.QtSvg.QSvgRenderer. repaintNeeded ( )
    PySide.QtSvg.QSvgRenderer. setCurrentFrame ( arg__1 )
    参数: arg__1 PySide.QtCore.int

    This property holds the current frame of the document's animation, or 0 if the document is not animated.

    PySide.QtSvg.QSvgRenderer. setFramesPerSecond ( num )
    参数: num PySide.QtCore.int

    This property holds the number of frames per second to be shown.

    The number of frames per second is 0 if the current document is not animated.

    PySide.QtSvg.QSvgRenderer. setViewBox ( viewbox )
    参数: viewbox PySide.QtCore.QRect
    PySide.QtSvg.QSvgRenderer. setViewBox ( viewbox )
    参数: viewbox PySide.QtCore.QRectF

    This property holds the rectangle specifying the visible area of the document in logical coordinates.

    PySide.QtSvg.QSvgRenderer. viewBox ( )
    返回类型: PySide.QtCore.QRect

    返回 PySide.QtSvg.QSvgRenderer.viewBoxF() . toRect() .

    PySide.QtSvg.QSvgRenderer. viewBoxF ( )
    返回类型: PySide.QtCore.QRectF

    This property holds the rectangle specifying the visible area of the document in logical coordinates.