Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 732

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?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>QGraphicsLayout 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">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QGraphicsLayout Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QGraphicsLayout class provides the base class for all
layouts in Graphics View. <a href="#details">More...</a></p>

<p>Inherits <a href="qgraphicslayoutitem.html">QGraphicsLayoutItem</a>.</p><p>Inherited by <a href="qgraphicsanchorlayout.html">QGraphicsAnchorLayout</a>, <a href="qgraphicsgridlayout.html">QGraphicsGridLayout</a> and <a href="qgraphicslinearlayout.html">QGraphicsLinearLayout</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qgraphicslayout.html#QGraphicsLayout">__init__</a></b> (<i>self</i>, QGraphicsLayoutItem&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qgraphicslayout.html#activate">activate</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicslayout.html#addChildLayoutItem">addChildLayoutItem</a></b> (<i>self</i>, QGraphicsLayoutItem&#160;<i>layoutItem</i>)</li><li><div class="fn" />int <b><a href="qgraphicslayout.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" />(float&#160;<i>left</i>, float&#160;<i>top</i>, float&#160;<i>right</i>, float&#160;<i>bottom</i>) <b><a href="qgraphicslayout.html#getContentsMargins">getContentsMargins</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicslayout.html#invalidate">invalidate</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qgraphicslayout.html#isActivated">isActivated</a></b> (<i>self</i>)</li><li><div class="fn" />QGraphicsLayoutItem <b><a href="qgraphicslayout.html#itemAt">itemAt</a></b> (<i>self</i>, int&#160;<i>i</i>)</li><li><div class="fn" /><b><a href="qgraphicslayout.html#removeAt">removeAt</a></b> (<i>self</i>, int&#160;<i>index</i>)</li><li><div class="fn" /><b><a href="qgraphicslayout.html#setContentsMargins">setContentsMargins</a></b> (<i>self</i>, float&#160;<i>left</i>, float&#160;<i>top</i>, float&#160;<i>right</i>, float&#160;<i>bottom</i>)</li><li><div class="fn" /><b><a href="qgraphicslayout.html#updateGeometry">updateGeometry</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgraphicslayout.html#widgetEvent">widgetEvent</a></b> (<i>self</i>, QEvent&#160;<i>e</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" /> <b><a href="qgraphicslayout.html#__len__">__len__</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QGraphicsLayout class provides the base class for all
layouts in Graphics View.</p>
<p>QGraphicsLayout is an abstract class that defines a virtual API
for arranging <a href="qgraphicswidget.html">QGraphicsWidget</a>
children and other <a href="qgraphicslayoutitem.html">QGraphicsLayoutItem</a> objects for a
<a href="qgraphicswidget.html">QGraphicsWidget</a>. <a href="qgraphicswidget.html">QGraphicsWidget</a> assigns responsibility
to a QGraphicsLayout through <a href="qgraphicswidget.html#layout-prop">QGraphicsWidget.setLayout</a>().
As the widget is resized, the layout will automatically arrange the
widget's children. QGraphicsLayout inherits <a href="qgraphicslayoutitem.html">QGraphicsLayoutItem</a>, so, it can be
managed by any layout, including its own subclasses.</p>
<a id="writing-a-custom-layout" name="writing-a-custom-layout" />
<h3>Writing a Custom Layout</h3>
<p>You can use QGraphicsLayout as a base to write your own custom
layout (e.g., a flowlayout), but it is more common to use one of
its subclasses instead - <a href="qgraphicslinearlayout.html">QGraphicsLinearLayout</a> or <a href="qgraphicsgridlayout.html">QGraphicsGridLayout</a>. When creating a
custom layout, the following functions must be reimplemented as a
bare minimum:</p>
<table class="generic">
<thead>
<tr class="qt-style">
<th>Function</th>
<th>Description</th>
</tr>
</thead>
<tr class="odd" valign="top">
<td><a href="qgraphicslayoutitem.html#setGeometry">QGraphicsLayoutItem.setGeometry</a>()</td>
<td>Notifies you when the geometry of the layout is set. You can
store the geometry in your own layout class in a reimplementation
of this function.</td>
</tr>
<tr class="even" valign="top">
<td><a href="qgraphicslayoutitem.html#sizeHint">QGraphicsLayoutItem.sizeHint</a>()</td>
<td>Returns the layout's size hints.</td>
</tr>
<tr class="odd" valign="top">
<td><a href="qgraphicslayout.html#count">QGraphicsLayout.count</a>()</td>
<td>Returns the number of items in your layout.</td>
</tr>
<tr class="even" valign="top">
<td><a href="qgraphicslayout.html#itemAt">QGraphicsLayout.itemAt</a>()</td>
<td>Returns a pointer to an item in your layout.</td>
</tr>
<tr class="odd" valign="top">
<td><a href="qgraphicslayout.html#removeAt">QGraphicsLayout.removeAt</a>()</td>
<td>Removes an item from your layout without destroying it.</td>
</tr>
</table>
<p>For more details on how to implement each function, refer to the
individual function documentation.</p>
<p>Each layout defines its own API for arranging widgets and layout
items. For example, with a grid layout, you require a row and a
column index with optional row and column spans, alignment,
spacing, and more. A linear layout, however, requires a single row
or column index to position its items. For a grid layout, the order
of insertion does not affect the layout in any way, but for a
linear layout, the order is essential. When writing your own layout
subclass, you are free to choose the API that best suits your
layout.</p>
<p>For adding layout items to the custom layout, the
QGraphicsLayout provides convenience function <a href="qgraphicslayout.html#addChildLayoutItem">addChildLayoutItem</a>().
The function will take care of automatically reparenting graphics
items, if needed.</p>
<a id="activating-the-layout" name="activating-the-layout" />
<h3>Activating the Layout</h3>
<p>When the layout's geometry changes, QGraphicsLayout immediately
rearranges all of its managed items by calling <a href="qgraphicslayoutitem.html#setGeometry">setGeometry</a>() on each
item. This rearrangement is called <i>activating</i> the
layout.</p>
<p>QGraphicsLayout updates its own geometry to match the <a href="qgraphicslayoutitem.html#contentsRect">contentsRect</a>() of the
<a href="qgraphicslayoutitem.html">QGraphicsLayoutItem</a> it is
managing. Thus, it will automatically rearrange all its items when
the widget is resized. QGraphicsLayout caches the sizes of all its
managed items to avoid calling <a href="qgraphicslayoutitem.html#setGeometry">setGeometry</a>() too
often.</p>
<p><b>Note:</b> A QGraphicsLayout will have the same geometry as
the <a href="qgraphicslayoutitem.html#contentsRect">contentsRect</a>() of the
widget (not the layout) it is assigned to.</p>
<a id="activating-the-layout-implicitly" name="activating-the-layout-implicitly" />
<h4>Activating the Layout Implicitly</h4>
<p>The layout can be activated implicitly using one of two ways: by
calling <a href="qgraphicslayout.html#activate">activate</a>() or
by calling <a href="qgraphicslayout.html#invalidate">invalidate</a>(). Calling
<a href="qgraphicslayout.html#activate">activate</a>() activates
the layout immediately. In contrast, calling <a href="qgraphicslayout.html#invalidate">invalidate</a>() is delayed, as
it posts a <a href="qevent.html#Type-enum">LayoutRequest</a> event
to the managed widget. Due to event compression, the <a href="qgraphicslayout.html#activate">activate</a>() will only be called
once after control has returned to the event loop. This is referred
to as <i>invalidating</i> the layout. Invalidating the layout also
invalidates any cached information. Also, the <a href="qgraphicslayout.html#invalidate">invalidate</a>() function is a
virtual function. So, you can invalidate your own cache in a
subclass of QGraphicsLayout by reimplementing this function.</p>
<a id="event-handling" name="event-handling" />
<h3>Event Handling</h3>
<p>QGraphicsLayout listens to events for the widget it manages
through the virtual <a href="qgraphicslayout.html#widgetEvent">widgetEvent</a>() event handler.
When the layout is assigned to a widget, all events delivered to
the widget are first processed by <a href="qgraphicslayout.html#widgetEvent">widgetEvent</a>(). This allows
the layout to be aware of any relevant state changes on the widget
such as visibility changes or layout direction changes.</p>
<a id="margin-handling" name="margin-handling" />
<h3>Margin Handling</h3>
<p>The margins of a QGraphicsLayout can be modified by
reimplementing <a href="qgraphicslayout.html#setContentsMargins">setContentsMargins</a>()
and <a href="qgraphicslayout.html#getContentsMargins">getContentsMargins</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGraphicsLayout" />QGraphicsLayout.__init__ (<i>self</i>, <a href="qgraphicslayoutitem.html">QGraphicsLayoutItem</a>&#160;<i>parent</i>&#160;=&#160;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>Contructs a <a href="qgraphicslayout.html">QGraphicsLayout</a>
object.</p>
<p><i>parent</i> is passed to <a href="qgraphicslayoutitem.html">QGraphicsLayoutItem</a>'s constructor
and the <a href="qgraphicslayoutitem.html">QGraphicsLayoutItem</a>'s isLayout
argument is set to <i>true</i>.</p>
<p>If <i>parent</i> is a <a href="qgraphicswidget.html">QGraphicsWidget</a> the layout will be
installed on that widget. (Note that installing a layout will
delete the old one installed.)</p>


<h3 class="fn"><a name="activate" />QGraphicsLayout.activate (<i>self</i>)</h3><p>Activates the layout, causing all items in the layout to be
immediately rearranged. This function is based on calling <a href="qgraphicslayout.html#count">count</a>() and <a href="qgraphicslayout.html#itemAt">itemAt</a>(), and then calling
<a href="qgraphicslayoutitem.html#setGeometry">setGeometry</a>() on
all items sequentially. When activated, the layout will adjust its
geometry to its parent's <a href="qgraphicslayoutitem.html#contentsRect">contentsRect</a>(). The
parent will then invalidate any layout of its own.</p>
<p>If called in sequence or recursively, e.g., by one of the
arranged items in response to being resized, this function will do
nothing.</p>
<p>Note that the layout is free to use geometry caching to optimize
this process. To forcefully invalidate any such cache, you can call
<a href="qgraphicslayout.html#invalidate">invalidate</a>() before
calling activate().</p>
<p><b>See also</b> <a href="qgraphicslayout.html#invalidate">invalidate</a>().</p>


<h3 class="fn"><a name="addChildLayoutItem" />QGraphicsLayout.addChildLayoutItem (<i>self</i>, <a href="qgraphicslayoutitem.html">QGraphicsLayoutItem</a>&#160;<i>layoutItem</i>)</h3><p>The <i>layoutItem</i> argument has it's ownership transferred to Qt.</p><p>This function is a convenience function provided for custom
layouts, and will go through all items in the layout and reparent
their graphics items to the closest <a href="qgraphicswidget.html">QGraphicsWidget</a> ancestor of the
layout.</p>
<p>If <i>layoutItem</i> is already in a different layout, it will
be removed from that layout.</p>
<p>If custom layouts want special behaviour they can ignore to use
this function, and implement their own behaviour.</p>
<p>This function was introduced in Qt 4.6.</p>
<p><b>See also</b> <a href="qgraphicslayoutitem.html#graphicsItem">graphicsItem</a>().</p>


<h3 class="fn"><a name="count" />int QGraphicsLayout.count (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This pure virtual function must be reimplemented in a subclass
of <a href="qgraphicslayout.html">QGraphicsLayout</a> to return the
number of items in the layout.</p>
<p>The subclass is free to decide how to store the items.</p>
<p><b>See also</b> <a href="qgraphicslayout.html#itemAt">itemAt</a>() and <a href="qgraphicslayout.html#removeAt">removeAt</a>().</p>


<h3 class="fn"><a name="getContentsMargins" />(float&#160;<i>left</i>, float&#160;<i>top</i>, float&#160;<i>right</i>, float&#160;<i>bottom</i>) QGraphicsLayout.getContentsMargins (<i>self</i>)</h3><p>Reimplemented from <a href="qgraphicslayoutitem.html#getContentsMargins">QGraphicsLayoutItem.getContentsMargins</a>().</p>


<h3 class="fn"><a name="invalidate" />QGraphicsLayout.invalidate (<i>self</i>)</h3><p>Clears any cached geometry and size hint information in the
layout, and posts a <a href="qevent.html#Type-enum">LayoutRequest</a> event to the managed
parent <a href="qgraphicslayoutitem.html">QGraphicsLayoutItem</a>.</p>
<p><b>See also</b> <a href="qgraphicslayout.html#activate">activate</a>() and <a href="qgraphicslayoutitem.html#setGeometry">setGeometry</a>().</p>


<h3 class="fn"><a name="isActivated" />bool QGraphicsLayout.isActivated (<i>self</i>)</h3><p>Returns true if the layout is currently being activated;
otherwise, returns false. If the layout is being activated, this
means that it is currently in the process of rearranging its items
(i.e., the <a href="qgraphicslayout.html#activate">activate</a>()
function has been called, and has not yet returned).</p>
<p><b>See also</b> <a href="qgraphicslayout.html#activate">activate</a>() and <a href="qgraphicslayout.html#invalidate">invalidate</a>().</p>


<h3 class="fn"><a name="itemAt" /><a href="qgraphicslayoutitem.html">QGraphicsLayoutItem</a> QGraphicsLayout.itemAt (<i>self</i>, int&#160;<i>i</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This pure virtual function must be reimplemented in a subclass
of <a href="qgraphicslayout.html">QGraphicsLayout</a> to return a
pointer to the item at index <i>i</i>. The reimplementation can
assume that <i>i</i> is valid (i.e., it respects the value of
<a href="qgraphicslayout.html#count">count</a>()). Together with
<a href="qgraphicslayout.html#count">count</a>(), it is provided as
a means of iterating over all items in a layout.</p>
<p>The subclass is free to decide how to store the items, and the
visual arrangement does not have to be reflected through this
function.</p>
<p><b>See also</b> <a href="qgraphicslayout.html#count">count</a>()
and <a href="qgraphicslayout.html#removeAt">removeAt</a>().</p>


<h3 class="fn"><a name="removeAt" />QGraphicsLayout.removeAt (<i>self</i>, int&#160;<i>index</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This pure virtual function must be reimplemented in a subclass
of <a href="qgraphicslayout.html">QGraphicsLayout</a> to remove the
item at <i>index</i>. The reimplementation can assume that
<i>index</i> is valid (i.e., it respects the value of <a href="qgraphicslayout.html#count">count</a>()).</p>
<p>The implementation must ensure that the <a href="qgraphicslayoutitem.html#parentLayoutItem">parentLayoutItem</a>()
of the removed item does not point to this layout, since the item
is considered to be removed from the layout hierarchy.</p>
<p>If the layout is to be reused between applications, we recommend
that the layout deletes the item, but the graphics view framework
does not depend on this.</p>
<p>The subclass is free to decide how to store the items.</p>
<p><b>See also</b> <a href="qgraphicslayout.html#itemAt">itemAt</a>() and <a href="qgraphicslayout.html#count">count</a>().</p>


<h3 class="fn"><a name="setContentsMargins" />QGraphicsLayout.setContentsMargins (<i>self</i>, float&#160;<i>left</i>, float&#160;<i>top</i>, float&#160;<i>right</i>, float&#160;<i>bottom</i>)</h3><p>Sets the contents margins to <i>left</i>, <i>top</i>,
<i>right</i> and <i>bottom</i>. The default contents margins for
toplevel layouts are style dependent (by querying the pixelMetric
for <a href="qstyle.html#PixelMetric-enum">QStyle.PM_LayoutLeftMargin</a>,
<a href="qstyle.html#PixelMetric-enum">QStyle.PM_LayoutTopMargin</a>,
<a href="qstyle.html#PixelMetric-enum">QStyle.PM_LayoutRightMargin</a> and
<a href="qstyle.html#PixelMetric-enum">QStyle.PM_LayoutBottomMargin</a>).</p>
<p>For sublayouts the default margins are 0.</p>
<p>Changing the contents margins automatically invalidates the
layout.</p>
<p><b>See also</b> <a href="qgraphicslayout.html#invalidate">invalidate</a>().</p>


<h3 class="fn"><a name="updateGeometry" />QGraphicsLayout.updateGeometry (<i>self</i>)</h3><p>Reimplemented from <a href="qgraphicslayoutitem.html#updateGeometry">QGraphicsLayoutItem.updateGeometry</a>().</p>


<h3 class="fn"><a name="widgetEvent" />QGraphicsLayout.widgetEvent (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>e</i>)</h3><p>This virtual event handler receives all events for the managed
widget. <a href="qgraphicslayout.html">QGraphicsLayout</a> uses
this event handler to listen for layout related events such as
geometry changes, layout changes or layout direction changes.</p>
<p><i>e</i> is a pointer to the event.</p>
<p>You can reimplement this event handler to track similar events
for your own custom layout.</p>
<p><b>See also</b> <a href="qgraphicswidget.html#event">QGraphicsWidget.event</a>() and
<a href="qgraphicsitem.html#sceneEvent">QGraphicsItem.sceneEvent</a>().</p>
<h3 class="fn"><a name="__len__" /> QGraphicsLayout.__len__ (<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&#160;4.10.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>