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 40 41 42 43
|
<?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>QGraphicsItemGroup 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">QGraphicsItemGroup Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QGraphicsItemGroup class provides treating a group of items as one. <a href="#details">More...</a></p>
<p>Inherits <a href="qgraphicsitem.html">QGraphicsItem</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qgraphicsitemgroup.html#QGraphicsItemGroup">__init__</a></b> (<i>self</i>, QGraphicsItem <i>parent</i> = None, QGraphicsScene <i>scene</i> = None)</li><li><div class="fn" /><b><a href="qgraphicsitemgroup.html#addToGroup">addToGroup</a></b> (<i>self</i>, QGraphicsItem)</li><li><div class="fn" />QRectF <b><a href="qgraphicsitemgroup.html#boundingRect">boundingRect</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qgraphicsitemgroup.html#isObscuredBy">isObscuredBy</a></b> (<i>self</i>, QGraphicsItem)</li><li><div class="fn" />QPainterPath <b><a href="qgraphicsitemgroup.html#opaqueArea">opaqueArea</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicsitemgroup.html#paint">paint</a></b> (<i>self</i>, QPainter, QStyleOptionGraphicsItem, QWidget <i>widget</i> = None)</li><li><div class="fn" /><b><a href="qgraphicsitemgroup.html#removeFromGroup">removeFromGroup</a></b> (<i>self</i>, QGraphicsItem)</li><li><div class="fn" />int <b><a href="qgraphicsitemgroup.html#type">type</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QGraphicsItemGroup class provides treating a group of items as one.</p>
<p>A QGraphicsItemGroup is a special type of compound item that treats itself and all its children as one item (i.e., all events and geometries for all children are merged together). It's common to use item groups in presentation tools, when the user wants to group several smaller items into one big item in order to simplify moving and copying of items.</p>
<p>If all you want is to store items inside other items, you can use any <a href="qgraphicsitem.html">QGraphicsItem</a> directly by passing a suitable parent to <a href="qgraphicsitem.html#setParentItem">setParentItem</a>().</p>
<p>The <a href="qgraphicsitemgroup.html#boundingRect">boundingRect</a>() function of QGraphicsItemGroup returns the bounding rectangle of all items in the item group. QGraphicsItemGroup ignores the <a href="qgraphicsitem.html#GraphicsItemFlag-enum">ItemIgnoresTransformations</a> flag on its children (i.e., with respect to the geometry of the group item, the children are treated as if they were transformable).</p>
<p>There are two ways to construct an item group. The easiest and most common approach is to pass a list of items (e.g., all selected items) to <a href="qgraphicsscene.html#createItemGroup">QGraphicsScene.createItemGroup</a>(), which returns a new QGraphicsItemGroup item. The other approach is to manually construct a QGraphicsItemGroup item, add it to the scene calling <a href="qgraphicsscene.html#addItem">QGraphicsScene.addItem</a>(), and then add items to the group manually, one at a time by calling <a href="qgraphicsitemgroup.html#addToGroup">addToGroup</a>(). To dismantle ("ungroup") an item group, you can either call <a href="qgraphicsscene.html#destroyItemGroup">QGraphicsScene.destroyItemGroup</a>(), or you can manually remove all items from the group by calling <a href="qgraphicsitemgroup.html#removeFromGroup">removeFromGroup</a>().</p>
<pre><span class="comment"> // Group all selected items together</span>
QGraphicsItemGroup *group = scene->createItemGroup(scene->selecteditems());
<span class="comment"> // Destroy the group, and delete the group item</span>
scene->destroyItemGroup(group);</pre>
<p>The operation of adding and removing items preserves the items' scene-relative position and transformation, as opposed to calling <a href="qgraphicsitem.html#setParentItem">setParentItem</a>(), where only the child item's parent-relative position and transformation are kept.</p>
<p>The addtoGroup() function reparents the target item to this item group, keeping the item's position and transformation intact relative to the scene. Visually, this means that items added via <a href="qgraphicsitemgroup.html#addToGroup">addToGroup</a>() will remain completely unchanged as a result of this operation, regardless of the item or the group's current position or transformation; although the item's position and matrix are likely to change.</p>
<p>The <a href="qgraphicsitemgroup.html#removeFromGroup">removeFromGroup</a>() function has similar semantics to <a href="qgraphicsitem.html#setParentItem">setParentItem</a>(); it reparents the item to the parent item of the item group. As with <a href="qgraphicsitemgroup.html#addToGroup">addToGroup</a>(), the item's scene-relative position and transformation remain intact.</p>
<p>See also <a href="qgraphicsitem.html">QGraphicsItem</a> and <a href="graphicsview.html">The Graphics View Framework</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGraphicsItemGroup" />QGraphicsItemGroup.__init__ (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a> <i>parent</i> = None, <a href="qgraphicsscene.html">QGraphicsScene</a> <i>scene</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>The <i>scene</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qgraphicsitemgroup.html">QGraphicsItemGroup</a>. <i>parent</i> is passed to <a href="qgraphicsitem.html">QGraphicsItem</a>'s constructor.</p>
<p>See also <a href="qgraphicsscene.html#addItem">QGraphicsScene.addItem</a>().</p>
<a name="//apple_ref/cpp/instm/QGraphicsItemGroup/~QGraphicsItemGroup" />
<h3 class="fn"><a name="addToGroup" />QGraphicsItemGroup.addToGroup (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a>)</h3><p>The <i>QGraphicsItem</i> argument has it's ownership transferred to Qt.</p><p>Adds the given <i>item</i> to this item group. The item will be reparented to this group, but its position and transformation relative to the scene will stay intact.</p>
<p>See also <a href="qgraphicsitemgroup.html#removeFromGroup">removeFromGroup</a>() and <a href="qgraphicsscene.html#createItemGroup">QGraphicsScene.createItemGroup</a>().</p>
<a name="//apple_ref/cpp/instm/QGraphicsItemGroup/boundingRect" />
<h3 class="fn"><a name="boundingRect" /><a href="qrectf.html">QRectF</a> QGraphicsItemGroup.boundingRect (<i>self</i>)</h3><p>Reimplemented from <a href="qgraphicsitem.html#boundingRect">QGraphicsItem.boundingRect</a>().</p>
<p>Returns the bounding rect of this group item, and all its children.</p>
<a name="//apple_ref/cpp/instm/QGraphicsItemGroup/isObscuredBy" />
<h3 class="fn"><a name="isObscuredBy" />bool QGraphicsItemGroup.isObscuredBy (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a>)</h3><p>Reimplemented from <a href="qgraphicsitem.html#isObscuredBy">QGraphicsItem.isObscuredBy</a>().</p>
<a name="//apple_ref/cpp/instm/QGraphicsItemGroup/opaqueArea" />
<h3 class="fn"><a name="opaqueArea" /><a href="qpainterpath.html">QPainterPath</a> QGraphicsItemGroup.opaqueArea (<i>self</i>)</h3><p>Reimplemented from <a href="qgraphicsitem.html#opaqueArea">QGraphicsItem.opaqueArea</a>().</p>
<a name="//apple_ref/cpp/instm/QGraphicsItemGroup/paint" />
<h3 class="fn"><a name="paint" />QGraphicsItemGroup.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/QGraphicsItemGroup/removeFromGroup" />
<h3 class="fn"><a name="removeFromGroup" />QGraphicsItemGroup.removeFromGroup (<i>self</i>, <a href="qgraphicsitem.html">QGraphicsItem</a>)</h3><p>Removes the specified <i>item</i> from this group. The item will be reparented to this group's parent item, or to 0 if this group has no parent. Its position and transformation relative to the scene will stay intact.</p>
<p>See also <a href="qgraphicsitemgroup.html#addToGroup">addToGroup</a>() and <a href="qgraphicsscene.html#destroyItemGroup">QGraphicsScene.destroyItemGroup</a>().</p>
<a name="//apple_ref/cpp/instm/QGraphicsItemGroup/type" />
<h3 class="fn"><a name="type" />int QGraphicsItemGroup.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>
|