<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qsvggenerator.cpp --> <title>QSvgGenerator Class | Qt SVG 5.9</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.9</td><td ><a href="qtsvg-index.html">Qt SVG</a></td><td ><a href="qtsvg-module.html">C++ Classes</a></td><td >QSvgGenerator</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#properties">Properties</a></li> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#protected-functions">Protected Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QSvgGenerator Class</h1> <!-- $$$QSvgGenerator-brief --> <p>The <a href="qsvggenerator.html">QSvgGenerator</a> class provides a paint device that is used to create SVG drawings. <a href="#details">More...</a></p> <!-- @@@QSvgGenerator --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QSvgGenerator></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += svg</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 4.3</td></tr></table></div><ul> <li><a href="qsvggenerator-members.html">List of all members, including inherited members</a></li> </ul> <p><b>Note:</b> All functions in this class are reentrant.</p> <a name="properties"></a> <h2 id="properties">Properties</h2> <div class="table"><table class="propsummary"> <tr><td class="topAlign"><ul> <li class="fn"><b><a href="qsvggenerator.html#description-prop">description</a></b> : QString</li> <li class="fn"><b><a href="qsvggenerator.html#fileName-prop">fileName</a></b> : QString</li> <li class="fn"><b><a href="qsvggenerator.html#outputDevice-prop">outputDevice</a></b> : QIODevice *</li> <li class="fn"><b><a href="qsvggenerator.html#resolution-prop">resolution</a></b> : int</li> </ul></td><td class="topAlign"><ul> <li class="fn"><b><a href="qsvggenerator.html#size-prop">size</a></b> : QSize</li> <li class="fn"><b><a href="qsvggenerator.html#title-prop">title</a></b> : QString</li> <li class="fn"><b><a href="qsvggenerator.html#viewBox-prop">viewBox</a></b> : QRectF</li> </ul> </td></tr> </table></div> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#QSvgGenerator">QSvgGenerator</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#dtor.QSvgGenerator">~QSvgGenerator</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#description-prop">description</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#fileName-prop">fileName</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QIODevice *</td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#outputDevice-prop">outputDevice</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#resolution-prop">resolution</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#description-prop">setDescription</a></b>(const QString &<i>description</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#fileName-prop">setFileName</a></b>(const QString &<i>fileName</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#outputDevice-prop">setOutputDevice</a></b>(QIODevice *<i>outputDevice</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#resolution-prop">setResolution</a></b>(int <i>dpi</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#size-prop">setSize</a></b>(const QSize &<i>size</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#title-prop">setTitle</a></b>(const QString &<i>title</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#viewBox-prop">setViewBox</a></b>(const QRect &<i>viewBox</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#viewBox-prop">setViewBox</a></b>(const QRectF &<i>viewBox</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QSize </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#size-prop">size</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#title-prop">title</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QRect </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#viewBox">viewBox</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QRectF </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#viewBox-prop">viewBoxF</a></b>() const</td></tr> </table></div> <a name="protected-functions"></a> <h2 id="protected-functions">Protected Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#metric">metric</a></b>(QPaintDevice::PaintDeviceMetric <i>metric</i>) const override</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QPaintEngine *</td><td class="memItemRight bottomAlign"><b><a href="qsvggenerator.html#paintEngine">paintEngine</a></b>() const override</td></tr> </table></div> <a name="details"></a> <!-- $$$QSvgGenerator-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qsvggenerator.html">QSvgGenerator</a> 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 QPrinter, 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"> </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 QPaintDevice subclasses, a QPainter object is used to paint onto an instance of this class:</p> <pre class="cpp"> ... </pre> <p>Painting is performed in the same way as for any other paint device. However, it is necessary to use the QPainter::begin() and end() to explicitly begin and end painting on the device.</p> <p>The SVG Generator Example shows how the same painting commands can be used for painting a widget and writing an SVG file.</p> </div> <p><b>See also </b><a href="qsvgrenderer.html">QSvgRenderer</a>, <a href="qsvgwidget.html">QSvgWidget</a>, and <a href="qtsvg-module.html">Qt SVG C++ Classes</a>.</p> <!-- @@@QSvgGenerator --> <div class="prop"> <h2>Property Documentation</h2> <!-- $$$description-prop$$$description$$$setDescriptionconstQString& --> <h3 class="fn" id="description-prop"><a name="description-prop"></a><span class="name">description</span> : <span class="type">QString</span></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> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>description</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setDescription</b></span>(const QString &<i>description</i>)</td></tr> </table></div> <p><b>See also </b><a href="qsvggenerator.html#title-prop">title</a>.</p> <!-- @@@description --> <!-- $$$fileName-prop$$$fileName$$$setFileNameconstQString& --> <h3 class="fn" id="fileName-prop"><a name="fileName-prop"></a><span class="name">fileName</span> : <span class="type">QString</span></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> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>fileName</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setFileName</b></span>(const QString &<i>fileName</i>)</td></tr> </table></div> <p><b>See also </b><a href="qsvggenerator.html#outputDevice-prop">outputDevice</a>.</p> <!-- @@@fileName --> <!-- $$$outputDevice-prop$$$outputDevice$$$setOutputDeviceQIODevice* --> <h3 class="fn" id="outputDevice-prop"><a name="outputDevice-prop"></a><span class="name">outputDevice</span> : <span class="type">QIODevice</span> *</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> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QIODevice *</td><td class="memItemRight bottomAlign"><span class="name"><b>outputDevice</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setOutputDevice</b></span>(QIODevice *<i>outputDevice</i>)</td></tr> </table></div> <p><b>See also </b><a href="qsvggenerator.html#fileName-prop">fileName</a>.</p> <!-- @@@outputDevice --> <!-- $$$resolution-prop$$$resolution$$$setResolutionint --> <h3 class="fn" id="resolution-prop"><a name="resolution-prop"></a><span class="name">resolution</span> : <span class="type">int</span></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> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> int </td><td class="memItemRight bottomAlign"><span class="name"><b>resolution</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setResolution</b></span>(int <i>dpi</i>)</td></tr> </table></div> <p><b>See also </b><a href="qsvggenerator.html#size-prop">size</a> and <a href="qsvggenerator.html#viewBox-prop">viewBox</a>.</p> <!-- @@@resolution --> <!-- $$$size-prop$$$size$$$setSizeconstQSize& --> <h3 class="fn" id="size-prop"><a name="size-prop"></a><span class="name">size</span> : <span class="type">QSize</span></h3> <p>This property holds the size of the generated SVG drawing</p> <p>By default this property is set to <code>QSize(-1, -1)</code>, which indicates that the generator should not output the width and height attributes of the <code><svg></code> element.</p> <p><b>Note: </b>It is not possible to change this property while a QPainter is active on the generator.</p><p>This property was introduced in Qt 4.5.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QSize </td><td class="memItemRight bottomAlign"><span class="name"><b>size</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setSize</b></span>(const QSize &<i>size</i>)</td></tr> </table></div> <p><b>See also </b><a href="qsvggenerator.html#viewBox-prop">viewBox</a> and <a href="qsvggenerator.html#resolution-prop">resolution</a>.</p> <!-- @@@size --> <!-- $$$title-prop$$$title$$$setTitleconstQString& --> <h3 class="fn" id="title-prop"><a name="title-prop"></a><span class="name">title</span> : <span class="type">QString</span></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> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>title</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setTitle</b></span>(const QString &<i>title</i>)</td></tr> </table></div> <p><b>See also </b><a href="qsvggenerator.html#description-prop">description</a>.</p> <!-- @@@title --> <!-- $$$viewBox-prop$$$viewBoxF$$$setViewBoxconstQRect&$$$setViewBoxconstQRectF& --> <h3 class="fn" id="viewBox-prop"><a name="viewBox-prop"></a><span class="name">viewBox</span> : <span class="type">QRectF</span></h3> <p>This property holds the viewBox of the generated SVG drawing</p> <p>By default this property is set to <code>QRect(0, 0, -1, -1)</code>, which indicates that the generator should not output the viewBox attribute of the <code><svg></code> element.</p> <p><b>Note: </b>It is not possible to change this property while a QPainter is active on the generator.</p><p>This property was introduced in Qt 4.5.</p> <p><b>Access functions:</b></p> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft topAlign rightAlign"> QRectF </td><td class="memItemRight bottomAlign"><span class="name"><b>viewBoxF</b></span>() const</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setViewBox</b></span>(const QRect &<i>viewBox</i>)</td></tr> <tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setViewBox</b></span>(const QRectF &<i>viewBox</i>)</td></tr> </table></div> <p><b>See also </b><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> <!-- @@@viewBox --> </div> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QSvgGenerator[overload1]$$$QSvgGenerator --> <h3 class="fn" id="QSvgGenerator"><a name="QSvgGenerator"></a>QSvgGenerator::<span class="name">QSvgGenerator</span>()</h3> <p>Constructs a new generator.</p> <!-- @@@QSvgGenerator --> <!-- $$$~QSvgGenerator[overload1]$$$~QSvgGenerator --> <h3 class="fn" id="dtor.QSvgGenerator"><a name="dtor.QSvgGenerator"></a>QSvgGenerator::<span class="name">~QSvgGenerator</span>()</h3> <p>Destroys the generator.</p> <!-- @@@~QSvgGenerator --> <!-- $$$metric[overload1]$$$metricQPaintDevice::PaintDeviceMetric --> <h3 class="fn" id="metric"><a name="metric"></a><code>[protected] </code><span class="type">int</span> QSvgGenerator::<span class="name">metric</span>(<span class="type">QPaintDevice::PaintDeviceMetric</span> <i>metric</i>) const</h3> <!-- @@@metric --> <!-- $$$paintEngine[overload1]$$$paintEngine --> <h3 class="fn" id="paintEngine"><a name="paintEngine"></a><code>[protected] </code><span class="type">QPaintEngine</span> *QSvgGenerator::<span class="name">paintEngine</span>() const</h3> <p>Returns the paint engine used to render graphics to be converted to SVG format information.</p> <!-- @@@paintEngine --> <!-- $$$viewBox[overload1]$$$viewBox --> <h3 class="fn" id="viewBox"><a name="viewBox"></a><span class="type">QRect</span> QSvgGenerator::<span class="name">viewBox</span>() 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><b>See also </b><a href="qsvggenerator.html#viewBox-prop">setViewBox</a>() and <a href="qsvggenerator.html#viewBox-prop">viewBoxF</a>().</p> <!-- @@@viewBox --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>