<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html><head><title>QSvgGenerator Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } td.postheader { font-family: sans-serif } tr.address { font-family: sans-serif } body { background: #ffffff; color: black; } </style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QSvgGenerator Class Reference<br /><sup><sup>[<a href="qtsvg.html">QtSvg</a> module]</sup></sup></h1><p>The QSvgGenerator class provides a paint device that is used to create SVG drawings. <a href="#details">More...</a></p> <p>Inherits <a href="qpaintdevice.html">QPaintDevice</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qsvggenerator.html#QSvgGenerator">__init__</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsvggenerator.html#description">description</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsvggenerator.html#fileName">fileName</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qsvggenerator.html#metric">metric</a></b> (<i>self</i>, QPaintDevice.PaintDeviceMetric <i>metric</i>)</li><li><div class="fn" />QIODevice <b><a href="qsvggenerator.html#outputDevice">outputDevice</a></b> (<i>self</i>)</li><li><div class="fn" />QPaintEngine <b><a href="qsvggenerator.html#paintEngine">paintEngine</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qsvggenerator.html#resolution">resolution</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsvggenerator.html#setDescription">setDescription</a></b> (<i>self</i>, QString <i>description</i>)</li><li><div class="fn" /><b><a href="qsvggenerator.html#setFileName">setFileName</a></b> (<i>self</i>, QString <i>fileName</i>)</li><li><div class="fn" /><b><a href="qsvggenerator.html#setOutputDevice">setOutputDevice</a></b> (<i>self</i>, QIODevice <i>outputDevice</i>)</li><li><div class="fn" /><b><a href="qsvggenerator.html#setResolution">setResolution</a></b> (<i>self</i>, int <i>resolution</i>)</li><li><div class="fn" /><b><a href="qsvggenerator.html#setSize">setSize</a></b> (<i>self</i>, QSize <i>size</i>)</li><li><div class="fn" /><b><a href="qsvggenerator.html#setTitle">setTitle</a></b> (<i>self</i>, QString <i>title</i>)</li><li><div class="fn" /><b><a href="qsvggenerator.html#setViewBox">setViewBox</a></b> (<i>self</i>, QRect <i>viewBox</i>)</li><li><div class="fn" /><b><a href="qsvggenerator.html#setViewBox-2">setViewBox</a></b> (<i>self</i>, QRectF <i>viewBox</i>)</li><li><div class="fn" />QSize <b><a href="qsvggenerator.html#size">size</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsvggenerator.html#title">title</a></b> (<i>self</i>)</li><li><div class="fn" />QRect <b><a href="qsvggenerator.html#viewBox">viewBox</a></b> (<i>self</i>)</li><li><div class="fn" />QRectF <b><a href="qsvggenerator.html#viewBoxF">viewBoxF</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QSvgGenerator class provides a paint device that is used to create SVG drawings.</p> <p>This paint device represents a Scalable Vector Graphics (SVG) drawing. Like <a href="qprinter.html">QPrinter</a>, it is designed as a write-only device that generates output in a specific format.</p> <p>To write an SVG file, you first need to configure the output by setting the <a href="qsvggenerator.html#fileName-prop">fileName</a> or <a href="qsvggenerator.html#outputDevice-prop">outputDevice</a> properties. It is usually necessary to specify the size of the drawing by setting the <a href="qsvggenerator.html#size-prop">size</a> property, and in some cases where the drawing will be included in another, the <a href="qsvggenerator.html#viewBox-prop">viewBox</a> property also needs to be set.</p> <pre class="cpp"> <span class="type">QSvgGenerator</span> generator; generator<span class="operator">.</span>setFileName(path); generator<span class="operator">.</span>setSize(<span class="type"><a href="qsize.html">QSize</a></span>(<span class="number">200</span><span class="operator">,</span> <span class="number">200</span>)); generator<span class="operator">.</span>setViewBox(<span class="type"><a href="qrect.html">QRect</a></span>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">200</span><span class="operator">,</span> <span class="number">200</span>)); generator<span class="operator">.</span>setTitle(tr(<span class="string">"SVG Generator Example Drawing"</span>)); generator<span class="operator">.</span>setDescription(tr(<span class="string">"An SVG drawing created by the SVG Generator "</span> <span class="string">"Example provided with Qt."</span>)); </pre> <p>Other meta-data can be specified by setting the <i>title</i>, <i>description</i> and <i>resolution</i> properties.</p> <p>As with other <a href="qpaintdevice.html">QPaintDevice</a> subclasses, a <a href="qpainter.html">QPainter</a> object is used to paint onto an instance of this class:</p> <pre class="cpp"> <span class="type"><a href="qpainter.html">QPainter</a></span> painter; painter<span class="operator">.</span>begin(<span class="operator">&</span>generator); ... painter<span class="operator">.</span>end(); </pre> <p>Painting is performed in the same way as for any other paint device. However, it is necessary to use the <a href="qpainter.html#begin">QPainter.begin</a>() and <a href="qpainter.html#end">end()</a> to explicitly begin and end painting on the device.</p> <p>The <a href="painting-svggenerator.html">SVG Generator Example</a> shows how the same painting commands can be used for painting a widget and writing an SVG file.</p> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSvgGenerator" />QSvgGenerator.__init__ (<i>self</i>)</h3><p>Constructs a new generator.</p> <h3 class="fn"><a name="description" />QString QSvgGenerator.description (<i>self</i>)</h3><h3 class="fn"><a name="fileName" />QString QSvgGenerator.fileName (<i>self</i>)</h3><h3 class="fn"><a name="metric" />int QSvgGenerator.metric (<i>self</i>, <a href="qpaintdevice.html#PaintDeviceMetric-enum">QPaintDevice.PaintDeviceMetric</a> <i>metric</i>)</h3><p>Reimplemented from <a href="qpaintdevice.html#metric">QPaintDevice.metric</a>().</p> <h3 class="fn"><a name="outputDevice" /><a href="qiodevice.html">QIODevice</a> QSvgGenerator.outputDevice (<i>self</i>)</h3><h3 class="fn"><a name="paintEngine" /><a href="qpaintengine.html">QPaintEngine</a> QSvgGenerator.paintEngine (<i>self</i>)</h3><p>Reimplemented from <a href="qpaintdevice.html#paintEngine">QPaintDevice.paintEngine</a>().</p> <p>Returns the paint engine used to render graphics to be converted to SVG format information.</p> <h3 class="fn"><a name="resolution" />int QSvgGenerator.resolution (<i>self</i>)</h3><h3 class="fn"><a name="setDescription" />QSvgGenerator.setDescription (<i>self</i>, QString <i>description</i>)</h3><h3 class="fn"><a name="setFileName" />QSvgGenerator.setFileName (<i>self</i>, QString <i>fileName</i>)</h3><h3 class="fn"><a name="setOutputDevice" />QSvgGenerator.setOutputDevice (<i>self</i>, <a href="qiodevice.html">QIODevice</a> <i>outputDevice</i>)</h3><h3 class="fn"><a name="setResolution" />QSvgGenerator.setResolution (<i>self</i>, int <i>resolution</i>)</h3><h3 class="fn"><a name="setSize" />QSvgGenerator.setSize (<i>self</i>, <a href="qsize.html">QSize</a> <i>size</i>)</h3><h3 class="fn"><a name="setTitle" />QSvgGenerator.setTitle (<i>self</i>, QString <i>title</i>)</h3><h3 class="fn"><a name="setViewBox" />QSvgGenerator.setViewBox (<i>self</i>, <a href="qrect.html">QRect</a> <i>viewBox</i>)</h3><h3 class="fn"><a name="setViewBox-2" />QSvgGenerator.setViewBox (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>viewBox</i>)</h3><h3 class="fn"><a name="size" /><a href="qsize.html">QSize</a> QSvgGenerator.size (<i>self</i>)</h3><h3 class="fn"><a name="title" />QString QSvgGenerator.title (<i>self</i>)</h3><h3 class="fn"><a name="viewBox" /><a href="qrect.html">QRect</a> QSvgGenerator.viewBox (<i>self</i>)</h3><p>Returns <a href="qsvggenerator.html#viewBox-prop">viewBoxF</a>().toRect().</p> <p>This function was introduced in Qt 4.5.</p> <p><b>See also</b> <a href="qsvggenerator.html#viewBox-prop">setViewBox</a>() and <a href="qsvggenerator.html#viewBox-prop">viewBoxF</a>().</p> <h3 class="fn"><a name="viewBoxF" /><a href="qrectf.html">QRectF</a> QSvgGenerator.viewBoxF (<i>self</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>