1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
<?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>QGraphicsSvgItem 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="../pyqt4ref.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">QGraphicsSvgItem Class Reference<br /><sup><sup>[<a href="qtsvg.html">QtSvg</a> module]</sup></sup></h1><p>The QGraphicsSvgItem class is a <a href="qgraphicsitem.html">QGraphicsItem</a> that can be used to render the contents of SVG files. <a href="#details">More...</a></p>
<p>Inherits <a href="qgraphicsobject.html">QGraphicsObject</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qgraphicssvgitem.html#QGraphicsSvgItem">__init__</a></b> (<i>self</i>, QGraphicsItem <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#QGraphicsSvgItem-2">__init__</a></b> (<i>self</i>, QString, QGraphicsItem <i>parent</i> = None)</li><li><div class="fn" />QRectF <b><a href="qgraphicssvgitem.html#boundingRect">boundingRect</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qgraphicssvgitem.html#elementId">elementId</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qgraphicssvgitem.html#isCachingEnabled">isCachingEnabled</a></b> (<i>self</i>)</li><li><div class="fn" />QSize <b><a href="qgraphicssvgitem.html#maximumCacheSize">maximumCacheSize</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#paint">paint</a></b> (<i>self</i>, QPainter, QStyleOptionGraphicsItem, QWidget <i>widget</i> = None)</li><li><div class="fn" />QSvgRenderer <b><a href="qgraphicssvgitem.html#renderer">renderer</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#setCachingEnabled">setCachingEnabled</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#setElementId">setElementId</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#setMaximumCacheSize">setMaximumCacheSize</a></b> (<i>self</i>, QSize)</li><li><div class="fn" /><b><a href="qgraphicssvgitem.html#setSharedRenderer">setSharedRenderer</a></b> (<i>self</i>, QSvgRenderer)</li><li><div class="fn" />int <b><a href="qgraphicssvgitem.html#type">type</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QGraphicsSvgItem class is a <a href="qgraphicsitem.html">QGraphicsItem</a> that can be used to render the contents of SVG files.</p>
<p>QGraphicsSvgItem provides a way of rendering SVG files onto <a href="qgraphicsview.html">QGraphicsView</a>. QGraphicsSvgItem can be created by passing the SVG file to be rendered to its constructor or by explicit setting a shared <a href="qsvgrenderer.html">QSvgRenderer</a> on it.</p>
<p>Note that setting <a href="qsvgrenderer.html">QSvgRenderer</a> on a QGraphicsSvgItem doesn't make the item take ownership of the renderer, therefore if using <a href="qgraphicssvgitem.html#setSharedRenderer">setSharedRenderer</a>() method one has to make sure that the lifetime of the <a href="qsvgrenderer.html">QSvgRenderer</a> object will be at least as long as that of the QGraphicsSvgItem.</p>
<p>QGraphicsSvgItem provides a way of rendering only parts of the SVG files via the setElementId. If <a href="qgraphicssvgitem.html#elementId-prop">setElementId</a>() method is called, only the SVG element (and its children) with the passed id will be renderer. This provides a convenient way of selectively rendering large SVG files that contain a number of discrete elements. For example the following code renders only jokers from a SVG file containing a whole card deck:</p>
<pre> QSvgRenderer *renderer = new QSvgRenderer(QLatin1String("SvgCardDeck.svg"));
QGraphicsSvgItem *black = new QGraphicsSvgItem();
QGraphicsSvgItem *red = new QGraphicsSvgItem();
black->setSharedRenderer(renderer);
black->setElementId(QLatin1String("black_joker"));
red->setSharedRenderer(renderer);
red->setElementId(QLatin1String("red_joker"));</pre>
<p>Size of the item can be set via the setSize() method or via direct manipulation of the items transformation matrix.</p>
<p>By default the SVG rendering is cached using <a href="qgraphicsitem.html#CacheMode-enum">QGraphicsItem.DeviceCoordinateCache</a> mode to speedup the display of items. Caching can be disabled by passing <a href="qgraphicsitem.html#CacheMode-enum">QGraphicsItem.NoCache</a> to the <a href="qgraphicsitem.html#setCacheMode">QGraphicsItem.setCacheMode</a>() method.</p>
<p>See also <a href="qsvgwidget.html">QSvgWidget</a>, <a href="qtsvg.html">QtSvg Module</a>, <a href="qgraphicsitem.html">QGraphicsItem</a>, and <a href="qgraphicsview.html">QGraphicsView</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGraphicsSvgItem" />QGraphicsSvgItem.__init__ (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a new SVG item with the given <i>parent</i>.</p>
<h3 class="fn"><a name="QGraphicsSvgItem-2" />QGraphicsSvgItem.__init__ (<i>self</i>, QString, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a new item with the given <i>parent</i> and loads the contents of the SVG file with the specified <i>fileName</i>.</p>
<a name="//apple_ref/cpp/instm/QGraphicsSvgItem/boundingRect" />
<h3 class="fn"><a name="boundingRect" /><a href="qrectf.html">QRectF</a> QGraphicsSvgItem.boundingRect (<i>self</i>)</h3><p>Reimplemented from <a href="qgraphicsitem.html#boundingRect">QGraphicsItem.boundingRect</a>().</p>
<p>Returns the bounding rectangle of this item.</p>
<a name="//apple_ref/cpp/instm/QGraphicsSvgItem/paint" />
<h3 class="fn"><a name="elementId" />QString QGraphicsSvgItem.elementId (<i>self</i>)</h3><h3 class="fn"><a name="isCachingEnabled" />bool QGraphicsSvgItem.isCachingEnabled (<i>self</i>)</h3><h3 class="fn"><a name="maximumCacheSize" /><a href="qsize.html">QSize</a> QGraphicsSvgItem.maximumCacheSize (<i>self</i>)</h3><h3 class="fn"><a name="paint" />QGraphicsSvgItem.paint (<i>self</i>, <a href="qpainter.html">QPainter</a>, <a href="qstyleoptiongraphicsitem.html">QStyleOptionGraphicsItem</a>, <a href="qwidget.html">QWidget</a> <i>widget</i> = None)</h3><p>Reimplemented from <a href="qgraphicsitem.html#paint">QGraphicsItem.paint</a>().</p>
<a name="//apple_ref/cpp/instm/QGraphicsSvgItem/renderer" />
<h3 class="fn"><a name="renderer" /><a href="qsvgrenderer.html">QSvgRenderer</a> QGraphicsSvgItem.renderer (<i>self</i>)</h3><p>Returns the currently use <a href="qsvgrenderer.html">QSvgRenderer</a>.</p>
<a name="//apple_ref/cpp/instm/QGraphicsSvgItem/setSharedRenderer" />
<h3 class="fn"><a name="setCachingEnabled" />QGraphicsSvgItem.setCachingEnabled (<i>self</i>, bool)</h3><h3 class="fn"><a name="setElementId" />QGraphicsSvgItem.setElementId (<i>self</i>, QString)</h3><h3 class="fn"><a name="setMaximumCacheSize" />QGraphicsSvgItem.setMaximumCacheSize (<i>self</i>, <a href="qsize.html">QSize</a>)</h3><h3 class="fn"><a name="setSharedRenderer" />QGraphicsSvgItem.setSharedRenderer (<i>self</i>, <a href="qsvgrenderer.html">QSvgRenderer</a>)</h3><p>Sets <i>renderer</i> to be a shared <a href="qsvgrenderer.html">QSvgRenderer</a> on the item. By using this method one can share the same <a href="qsvgrenderer.html">QSvgRenderer</a> on a number of items. This means that the SVG file will be parsed only once. <a href="qsvgrenderer.html">QSvgRenderer</a> passed to this method has to exist for as long as this item is used.</p>
<a name="//apple_ref/cpp/instm/QGraphicsSvgItem/type" />
<h3 class="fn"><a name="type" />int QGraphicsSvgItem.type (<i>self</i>)</h3><p>Reimplemented from <a href="qgraphicsitem.html#type">QGraphicsItem.type</a>().</p>
<p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.7.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> 2010</td><td align="right" width="25%">Qt 4.6.2</td></tr></table></div></address></body></html>
|