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

    上一话题

    PySide.QtSvg

    下一话题

    QSvgRenderer

    QSvgGenerator

    概要

    函数

    详细描述

    PySide.QtSvg.QSvgGenerator class provides a paint device that is used to create SVG drawings.

    This paint device represents a Scalable Vector Graphics (SVG) drawing. Like PySide.QtGui.QPrinter , it is designed as a write-only device that generates output in a specific format.

    To write an SVG file, you first need to configure the output by setting the PySide.QtSvg.QSvgGenerator.fileName() or PySide.QtSvg.QSvgGenerator.outputDevice() properties. It is usually necessary to specify the size of the drawing by setting the PySide.QtSvg.QSvgGenerator.size() property, and in some cases where the drawing will be included in another, the PySide.QtSvg.QSvgGenerator.viewBox() property also needs to be set.

    generator = QSvgGenerator()
    generator.setFileName(path)
    generator.setSize(QSize(200, 200))
    generator.setViewBox(QRect(0, 0, 200, 200))
    generator.setTitle(QObject.tr("SVG Generator Example Drawing"))
    generator.setDescription(QObject.tr("An SVG drawing created by the SVG Generator Example provided with Qt."))
    										

    Other meta-data can be specified by setting the title , description and resolution 特性。

    As with other PySide.QtGui.QPaintDevice subclasses, a PySide.QtGui.QPainter object is used to paint onto an instance of this class:

    painter = QPainter()
    painter.begin(generator)
    ...
    painter.end()
    										

    Painting is performed in the same way as for any other paint device. However, it is necessary to use the QPainter.begin() and PySide.QtGui.QPainter.end() to explicitly begin and end painting on the device.

    SVG Generator Example shows how the same painting commands can be used for painting a widget and writing an SVG file.

    class PySide.QtSvg. QSvgGenerator

    Constructs a new generator.

    PySide.QtSvg.QSvgGenerator. description ( )
    返回类型: unicode

    This property holds the description of the generated SVG drawing.

    PySide.QtSvg.QSvgGenerator. fileName ( )
    返回类型: unicode

    This property holds the target filename for the generated SVG drawing.

    PySide.QtSvg.QSvgGenerator. outputDevice ( )
    返回类型: PySide.QtCore.QIODevice

    This property holds the output device for the generated SVG drawing.

    If both output device and file name are specified, the output device will have precedence.

    PySide.QtSvg.QSvgGenerator. resolution ( )
    返回类型: PySide.QtCore.int

    This property holds the resolution of the generated output.

    The resolution is specified in dots per inch, and is used to calculate the physical size of an SVG drawing.

    PySide.QtSvg.QSvgGenerator. setDescription ( description )
    参数: description – unicode

    This property holds the description of the generated SVG drawing.

    PySide.QtSvg.QSvgGenerator. setFileName ( fileName )
    参数: fileName – unicode

    This property holds the target filename for the generated SVG drawing.

    PySide.QtSvg.QSvgGenerator. setOutputDevice ( outputDevice )
    参数: outputDevice PySide.QtCore.QIODevice

    This property holds the output device for the generated SVG drawing.

    If both output device and file name are specified, the output device will have precedence.

    PySide.QtSvg.QSvgGenerator. setResolution ( dpi )
    参数: dpi PySide.QtCore.int

    This property holds the resolution of the generated output.

    The resolution is specified in dots per inch, and is used to calculate the physical size of an SVG drawing.

    PySide.QtSvg.QSvgGenerator. setSize ( size )
    参数: size PySide.QtCore.QSize

    This property holds the size of the generated SVG drawing.

    By default this property is set to QSize(-1, -1) , which indicates that the generator should not output the width and height attributes of the <svg> 元素。

    注意

    It is not possible to change this property while a PySide.QtGui.QPainter is active on the generator.

    PySide.QtSvg.QSvgGenerator. setTitle ( title )
    参数: title – unicode

    This property holds the title of the generated SVG drawing.

    PySide.QtSvg.QSvgGenerator. setViewBox ( viewBox )
    参数: viewBox PySide.QtCore.QRectF

    此特性保持 PySide.QtSvg.QSvgGenerator.viewBox() of the generated SVG drawing.

    By default this property is set to QRect(0, 0, -1, -1) , which indicates that the generator should not output the PySide.QtSvg.QSvgGenerator.viewBox() attribute of the <svg> 元素。

    注意

    It is not possible to change this property while a PySide.QtGui.QPainter is active on the generator.

    PySide.QtSvg.QSvgGenerator. setViewBox ( viewBox )
    参数: viewBox PySide.QtCore.QRect
    PySide.QtSvg.QSvgGenerator. size ( )
    返回类型: PySide.QtCore.QSize

    This property holds the size of the generated SVG drawing.

    By default this property is set to QSize(-1, -1) , which indicates that the generator should not output the width and height attributes of the <svg> 元素。

    注意

    It is not possible to change this property while a PySide.QtGui.QPainter is active on the generator.

    PySide.QtSvg.QSvgGenerator. title ( )
    返回类型: unicode

    This property holds the title of the generated SVG drawing.

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

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

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

    此特性保持 PySide.QtSvg.QSvgGenerator.viewBox() of the generated SVG drawing.

    By default this property is set to QRect(0, 0, -1, -1) , which indicates that the generator should not output the PySide.QtSvg.QSvgGenerator.viewBox() attribute of the <svg> 元素。

    注意

    It is not possible to change this property while a PySide.QtGui.QPainter is active on the generator.