<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- qsvggenerator.cpp --> <head> <title>Qt 4.6: QSvgGenerator Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <a name="//apple_ref/cpp/cl//QSvgGenerator"></a> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></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="functions.html"><font color="#004faf">All Functions</font></a> · <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">QSvgGenerator Class Reference<br /><span class="small-subtitle">[<a href="qtsvg.html">QtSvg</a> module]</span> </h1> <p>The QSvgGenerator class provides a paint device that is used to create SVG drawings. <a href="#details">More...</a></p> <pre> #include <QSvgGenerator></pre><p><b>This class is not part of the Qt GUI Framework Edition.</b></p> <p>Inherits <a href="qpaintdevice.html">QPaintDevice</a>.</p> <p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p> <p>This class was introduced in Qt 4.3.</p> <ul> <li><a href="qsvggenerator-members.html">List of all members, including inherited members</a></li> </ul> <hr /> <a name="properties"></a> <h2>Properties</h2> <p><table class="propsummary" width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td width="45%" valign="top"><ul> <li><div class="fn"><b><a href="qsvggenerator.html#description-prop">description</a></b> : QString</div></li> <li><div class="fn"><b><a href="qsvggenerator.html#fileName-prop">fileName</a></b> : QString</div></li> <li><div class="fn"><b><a href="qsvggenerator.html#outputDevice-prop">outputDevice</a></b> : QIODevice *</div></li> <li><div class="fn"><b><a href="qsvggenerator.html#resolution-prop">resolution</a></b> : int</div></li> </ul></td><td valign="top"><ul> <li><div class="fn"><b><a href="qsvggenerator.html#size-prop">size</a></b> : QSize</div></li> <li><div class="fn"><b><a href="qsvggenerator.html#title-prop">title</a></b> : QString</div></li> <li><div class="fn"><b><a href="qsvggenerator.html#viewBox-prop">viewBox</a></b> : QRectF</div></li> </ul> </td></tr> </table></p> <hr /> <a name="public-functions"></a> <h2>Public Functions</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#QSvgGenerator">QSvgGenerator</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#dtor.QSvgGenerator">~QSvgGenerator</a></b> ()</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#description-prop">description</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#fileName-prop">fileName</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QIODevice * </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#outputDevice-prop">outputDevice</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#resolution-prop">resolution</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#description-prop">setDescription</a></b> ( const QString & <i>description</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#fileName-prop">setFileName</a></b> ( const QString & <i>fileName</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#outputDevice-prop">setOutputDevice</a></b> ( QIODevice * <i>outputDevice</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#resolution-prop">setResolution</a></b> ( int <i>dpi</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#size-prop">setSize</a></b> ( const QSize & <i>size</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#title-prop">setTitle</a></b> ( const QString & <i>title</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#viewBox-prop">setViewBox</a></b> ( const QRect & <i>viewBox</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#viewBox-prop">setViewBox</a></b> ( const QRectF & <i>viewBox</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QSize </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#size-prop">size</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#title-prop">title</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QRect </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#viewBox">viewBox</a></b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">QRectF </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#viewBox-prop">viewBoxF</a></b> () const</td></tr> </table> <ul> <li><div bar="2" class="fn"></div>13 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li> </ul> <hr /> <a name="reimplemented-protected-functions"></a> <h2>Reimplemented Protected Functions</h2> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">virtual int </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#metric">metric</a></b> ( QPaintDevice::PaintDeviceMetric <i>metric</i> ) const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">virtual QPaintEngine * </td><td class="memItemRight" valign="bottom"><b><a href="qsvggenerator.html#paintEngine">paintEngine</a></b> () const</td></tr> </table> <ul> <li><div bar="2" class="fn"></div>1 protected function inherited from <a href="qpaintdevice.html#protected-functions">QPaintDevice</a></li> </ul> <a name="details"></a> <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> QSvgGenerator generator; generator.setFileName(path); generator.setSize(QSize(200, 200)); generator.setViewBox(QRect(0, 0, 200, 200)); generator.setTitle(tr("SVG Generator Example Drawing")); generator.setDescription(tr("An SVG drawing created by the SVG Generator " "Example provided with Qt."));</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> QPainter painter; painter.begin(&generator); ... painter.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> <p>See also <a href="qsvgrenderer.html">QSvgRenderer</a>, <a href="qsvgwidget.html">QSvgWidget</a>, and <a href="http://www.w3.org/Graphics/SVG/About.html">About SVG</a>.</p> <hr /> <h2>Property Documentation</h2> <a name="//apple_ref/cpp/instm/QSvgGenerator/description"></a> <a name="//apple_ref/cpp/instm/QSvgGenerator/setDescription"></a> <h3 class="fn"><a name="description-prop"></a>description : <a href="qstring.html">QString</a></h3> <p>This property holds the description of the generated SVG drawing.</p> <p>This property was introduced in Qt 4.5.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b>description</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setDescription</b> ( const QString & <i>description</i> )</td></tr> </table> <p>See also <a href="qsvggenerator.html#title-prop">title</a>.</p> <a name="//apple_ref/cpp/instm/QSvgGenerator/fileName"></a> <a name="//apple_ref/cpp/instm/QSvgGenerator/setFileName"></a> <h3 class="fn"><a name="fileName-prop"></a>fileName : <a href="qstring.html">QString</a></h3> <p>This property holds the target filename for the generated SVG drawing.</p> <p>This property was introduced in Qt 4.5.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b>fileName</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setFileName</b> ( const QString & <i>fileName</i> )</td></tr> </table> <p>See also <a href="qsvggenerator.html#outputDevice-prop">outputDevice</a>.</p> <a name="//apple_ref/cpp/instm/QSvgGenerator/outputDevice"></a> <a name="//apple_ref/cpp/instm/QSvgGenerator/setOutputDevice"></a> <h3 class="fn"><a name="outputDevice-prop"></a>outputDevice : <a href="qiodevice.html">QIODevice</a> *</h3> <p>This property holds the output device for the generated SVG drawing.</p> <p>If both output device and file name are specified, the output device will have precedence.</p> <p>This property was introduced in Qt 4.5.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">QIODevice * </td><td class="memItemRight" valign="bottom"><b>outputDevice</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setOutputDevice</b> ( QIODevice * <i>outputDevice</i> )</td></tr> </table> <p>See also <a href="qsvggenerator.html#fileName-prop">fileName</a>.</p> <a name="//apple_ref/cpp/instm/QSvgGenerator/resolution"></a> <a name="//apple_ref/cpp/instm/QSvgGenerator/setResolution"></a> <h3 class="fn"><a name="resolution-prop"></a>resolution : int</h3> <p>This property holds the resolution of the generated output.</p> <p>The resolution is specified in dots per inch, and is used to calculate the physical size of an SVG drawing.</p> <p>This property was introduced in Qt 4.5.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><b>resolution</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setResolution</b> ( int <i>dpi</i> )</td></tr> </table> <p>See also <a href="qsvggenerator.html#size-prop">size</a> and <a href="qsvggenerator.html#viewBox-prop">viewBox</a>.</p> <a name="//apple_ref/cpp/instm/QSvgGenerator/size"></a> <a name="//apple_ref/cpp/instm/QSvgGenerator/setSize"></a> <h3 class="fn"><a name="size-prop"></a>size : <a href="qsize.html">QSize</a></h3> <p>This property holds the size of the generated SVG drawing.</p> <p>By default this property is set to <tt>QSize(-1, -1)</tt>, which indicates that the generator should not output the width and height attributes of the <tt><svg></tt> element.</p> <p><b>Note:</b> It is not possible to change this property while a <a href="qpainter.html">QPainter</a> is active on the generator.</p> <p>This property was introduced in Qt 4.5.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">QSize </td><td class="memItemRight" valign="bottom"><b>size</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setSize</b> ( const QSize & <i>size</i> )</td></tr> </table> <p>See also <a href="qsvggenerator.html#viewBox-prop">viewBox</a> and <a href="qsvggenerator.html#resolution-prop">resolution</a>.</p> <a name="//apple_ref/cpp/instm/QSvgGenerator/title"></a> <a name="//apple_ref/cpp/instm/QSvgGenerator/setTitle"></a> <h3 class="fn"><a name="title-prop"></a>title : <a href="qstring.html">QString</a></h3> <p>This property holds the title of the generated SVG drawing.</p> <p>This property was introduced in Qt 4.5.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">QString </td><td class="memItemRight" valign="bottom"><b>title</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setTitle</b> ( const QString & <i>title</i> )</td></tr> </table> <p>See also <a href="qsvggenerator.html#description-prop">description</a>.</p> <a name="//apple_ref/cpp/instm/QSvgGenerator/viewBoxF"></a> <a name="//apple_ref/cpp/instm/QSvgGenerator/setViewBox"></a> <h3 class="fn"><a name="viewBox-prop"></a>viewBox : <a href="qrectf.html">QRectF</a></h3> <p>This property holds the viewBox of the generated SVG drawing.</p> <p>By default this property is set to <tt>QRect(0, 0, -1, -1)</tt>, which indicates that the generator should not output the viewBox attribute of the <tt><svg></tt> element.</p> <p><b>Note:</b> It is not possible to change this property while a <a href="qpainter.html">QPainter</a> is active on the generator.</p> <p>This property was introduced in Qt 4.5.</p> <p><b>Access functions:</b></p> <table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%"> <tr><td class="memItemLeft" align="right" valign="top">QRectF </td><td class="memItemRight" valign="bottom"><b>viewBoxF</b> () const</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setViewBox</b> ( const QRect & <i>viewBox</i> )</td></tr> <tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b>setViewBox</b> ( const QRectF & <i>viewBox</i> )</td></tr> </table> <p>See also <a href="qsvggenerator.html#viewBox">viewBox</a>(), <a href="qsvggenerator.html#size-prop">size</a>, and <a href="qsvggenerator.html#resolution-prop">resolution</a>.</p> <hr /> <h2>Member Function Documentation</h2> <a name="//apple_ref/cpp/instm/QSvgGenerator/QSvgGenerator"></a> <h3 class="fn"><a name="QSvgGenerator"></a>QSvgGenerator::QSvgGenerator ()</h3> <p>Constructs a new generator.</p> <a name="//apple_ref/cpp/instm/QSvgGenerator/~QSvgGenerator"></a> <h3 class="fn"><a name="dtor.QSvgGenerator"></a>QSvgGenerator::~QSvgGenerator ()</h3> <p>Destroys the generator.</p> <a name="//apple_ref/cpp/instm/QSvgGenerator/metric"></a> <h3 class="fn"><a name="metric"></a>int QSvgGenerator::metric ( <a href="qpaintdevice.html#PaintDeviceMetric-enum">QPaintDevice::PaintDeviceMetric</a> <i>metric</i> ) const <tt> [virtual protected]</tt></h3> <p>Reimplemented from <a href="qpaintdevice.html#metric">QPaintDevice::metric</a>().</p> <a name="//apple_ref/cpp/instm/QSvgGenerator/paintEngine"></a> <h3 class="fn"><a name="paintEngine"></a><a href="qpaintengine.html">QPaintEngine</a> * QSvgGenerator::paintEngine () const <tt> [virtual protected]</tt></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> <a name="//apple_ref/cpp/instm/QSvgGenerator/viewBox"></a> <h3 class="fn"><a name="viewBox"></a><a href="qrect.html">QRect</a> QSvgGenerator::viewBox () const</h3> <p>Returns <a href="qsvggenerator.html#viewBox-prop">viewBoxF</a>().toRect().</p> <p>This function was introduced in Qt 4.5.</p> <p>See also <a href="qsvggenerator.html#viewBox-prop">setViewBox</a>() and <a href="qsvggenerator.html#viewBox-prop">viewBoxF</a>().</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="40%" align="left">Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies)</td> <td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="40%" align="right"><div align="right">Qt 4.6.3</div></td> </tr></table></div></address></body> </html>