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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
<?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>QStackedLayout 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="index.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">QStackedLayout Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QStackedLayout class provides a stack of widgets where only
one widget is visible at a time. <a href="#details">More...</a></p>
<p>Inherits <a href="qlayout.html">QLayout</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qstackedlayout.html#StackingMode-enum">StackingMode</a></b> { StackOne, StackAll }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qstackedlayout.html#QStackedLayout">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstackedlayout.html#QStackedLayout-2">__init__</a></b> (<i>self</i>, QWidget <i>parent</i>)</li><li><div class="fn" /><b><a href="qstackedlayout.html#QStackedLayout-3">__init__</a></b> (<i>self</i>, QLayout <i>parentLayout</i>)</li><li><div class="fn" /><b><a href="qstackedlayout.html#addItem">addItem</a></b> (<i>self</i>, QLayoutItem <i>item</i>)</li><li><div class="fn" />int <b><a href="qstackedlayout.html#addWidget">addWidget</a></b> (<i>self</i>, QWidget <i>w</i>)</li><li><div class="fn" />int <b><a href="qstackedlayout.html#count">count</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstackedlayout.html#currentIndex">currentIndex</a></b> (<i>self</i>)</li><li><div class="fn" />QWidget <b><a href="qstackedlayout.html#currentWidget">currentWidget</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qstackedlayout.html#insertWidget">insertWidget</a></b> (<i>self</i>, int <i>index</i>, QWidget <i>w</i>)</li><li><div class="fn" />QLayoutItem <b><a href="qstackedlayout.html#itemAt">itemAt</a></b> (<i>self</i>, int)</li><li><div class="fn" />QSize <b><a href="qstackedlayout.html#minimumSize">minimumSize</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qstackedlayout.html#setCurrentIndex">setCurrentIndex</a></b> (<i>self</i>, int <i>index</i>)</li><li><div class="fn" /><b><a href="qstackedlayout.html#setCurrentWidget">setCurrentWidget</a></b> (<i>self</i>, QWidget <i>w</i>)</li><li><div class="fn" /><b><a href="qstackedlayout.html#setGeometry">setGeometry</a></b> (<i>self</i>, QRect <i>rect</i>)</li><li><div class="fn" /><b><a href="qstackedlayout.html#setStackingMode">setStackingMode</a></b> (<i>self</i>, StackingMode <i>stackingMode</i>)</li><li><div class="fn" />QSize <b><a href="qstackedlayout.html#sizeHint">sizeHint</a></b> (<i>self</i>)</li><li><div class="fn" />StackingMode <b><a href="qstackedlayout.html#stackingMode">stackingMode</a></b> (<i>self</i>)</li><li><div class="fn" />QLayoutItem <b><a href="qstackedlayout.html#takeAt">takeAt</a></b> (<i>self</i>, int)</li><li><div class="fn" />QWidget <b><a href="qstackedlayout.html#widget">widget</a></b> (<i>self</i>, int)</li><li><div class="fn" />QWidget <b><a href="qstackedlayout.html#widget-2">widget</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qstackedlayout.html#currentChanged">currentChanged</a></b> (int)</li><li><div class="fn" />void <b><a href="qstackedlayout.html#widgetRemoved">widgetRemoved</a></b> (int)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QStackedLayout class provides a stack of widgets where only
one widget is visible at a time.</p>
<p>QStackedLayout can be used to create a user interface similar to
the one provided by <a href="qtabwidget.html">QTabWidget</a>. There
is also a convenience <a href="qstackedwidget.html">QStackedWidget</a> class built on top of
QStackedLayout.</p>
<p>A QStackedLayout can be populated with a number of child widgets
("pages"). For example:</p>
<pre class="cpp">
<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>firstPageWidget <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qwidget.html">QWidget</a></span>;
<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>secondPageWidget <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qwidget.html">QWidget</a></span>;
<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>thirdPageWidget <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qwidget.html">QWidget</a></span>;
<span class="type">QStackedLayout</span> <span class="operator">*</span>stackedLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QStackedLayout</span>;
stackedLayout<span class="operator">-</span><span class="operator">></span>addWidget(firstPageWidget);
stackedLayout<span class="operator">-</span><span class="operator">></span>addWidget(secondPageWidget);
stackedLayout<span class="operator">-</span><span class="operator">></span>addWidget(thirdPageWidget);
<span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>mainLayout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qvboxlayout.html">QVBoxLayout</a></span>;
mainLayout<span class="operator">-</span><span class="operator">></span>addLayout(stackedLayout);
setLayout(mainLayout);
</pre>
<p>QStackedLayout provides no intrinsic means for the user to
switch page. This is typically done through a <a href="qcombobox.html">QComboBox</a> or a <a href="qlistwidget.html">QListWidget</a> that stores the titles of the
QStackedLayout's pages. For example:</p>
<pre class="cpp">
<span class="type"><a href="qcombobox.html">QComboBox</a></span> <span class="operator">*</span>pageComboBox <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qcombobox.html">QComboBox</a></span>;
pageComboBox<span class="operator">-</span><span class="operator">></span>addItem(tr(<span class="string">"Page 1"</span>));
pageComboBox<span class="operator">-</span><span class="operator">></span>addItem(tr(<span class="string">"Page 2"</span>));
pageComboBox<span class="operator">-</span><span class="operator">></span>addItem(tr(<span class="string">"Page 3"</span>));
connect(pageComboBox<span class="operator">,</span> SIGNAL(activated(<span class="type">int</span>))<span class="operator">,</span>
stackedLayout<span class="operator">,</span> SLOT(setCurrentIndex(<span class="type">int</span>)));
</pre>
<p>When populating a layout, the widgets are added to an internal
list. The <a href="qlayout.html#indexOf">indexOf</a>() function
returns the index of a widget in that list. The widgets can either
be added to the end of the list using the <a href="qstackedlayout.html#addWidget">addWidget</a>() function, or
inserted at a given index using the <a href="qstackedlayout.html#insertWidget">insertWidget</a>() function. The
<a href="qlayout.html#removeWidget">removeWidget</a>() function
removes the widget at the given index from the layout. The number
of widgets contained in the layout, can be obtained using the
<a href="qstackedlayout.html#count-prop">count</a>() function.</p>
<p>The <a href="qstackedlayout.html#widget">widget</a>() function
returns the widget at a given index position. The index of the
widget that is shown on screen is given by <a href="qstackedlayout.html#currentIndex-prop">currentIndex</a>() and can
be changed using <a href="qstackedlayout.html#currentIndex-prop">setCurrentIndex</a>(). In a
similar manner, the currently shown widget can be retrieved using
the <a href="qstackedlayout.html#currentWidget">currentWidget</a>()
function, and altered using the <a href="qstackedlayout.html#setCurrentWidget">setCurrentWidget</a>()
function.</p>
<p>Whenever the current widget in the layout changes or a widget is
removed from the layout, the <a href="qstackedlayout.html#currentChanged">currentChanged</a>() and
<a href="qstackedlayout.html#widgetRemoved">widgetRemoved</a>()
signals are emitted respectively.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="StackingMode-enum" />QStackedLayout.StackingMode</h3><p>This enum specifies how the layout handles its child widgets
regarding their visibility.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QStackedLayout.StackOne</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">Only the current widget is visible. This is
the default.</td>
</tr>
<tr>
<td class="topAlign"><tt>QStackedLayout.StackAll</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">All widgets are visible. The current widget is
merely raised.</td>
</tr>
</table>
<p>This enum was introduced or modified in Qt 4.4.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QStackedLayout" />QStackedLayout.__init__ (<i>self</i>)</h3><p>Constructs a <a href="qstackedlayout.html">QStackedLayout</a>
with no parent.</p>
<p>This <a href="qstackedlayout.html">QStackedLayout</a> must be
installed on a widget later on to become effective.</p>
<p><b>See also</b> <a href="qstackedlayout.html#addWidget">addWidget</a>() and <a href="qstackedlayout.html#insertWidget">insertWidget</a>().</p>
<h3 class="fn"><a name="QStackedLayout-2" />QStackedLayout.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>parent</i>)</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 <a href="qstackedlayout.html">QStackedLayout</a> with the given
<i>parent</i>.</p>
<p>This layout will install itself on the <i>parent</i> widget and
manage the geometry of its children.</p>
<h3 class="fn"><a name="QStackedLayout-3" />QStackedLayout.__init__ (<i>self</i>, <a href="qlayout.html">QLayout</a> <i>parentLayout</i>)</h3><p>The <i>parentLayout</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a new <a href="qstackedlayout.html">QStackedLayout</a> and inserts it into the
given <i>parentLayout</i>.</p>
<h3 class="fn"><a name="addItem" />QStackedLayout.addItem (<i>self</i>, <a href="qlayoutitem.html">QLayoutItem</a> <i>item</i>)</h3><p>The <i>item</i> argument has it's ownership transferred to Qt.</p><p>Reimplemented from <a href="qlayout.html#addItem">QLayout.addItem</a>().</p>
<h3 class="fn"><a name="addWidget" />int QStackedLayout.addWidget (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>w</i>)</h3><p>Adds the given <i>widget</i> to the end of this layout and
returns the index position of the <i>widget</i>.</p>
<p>If the <a href="qstackedlayout.html">QStackedLayout</a> is empty
before this function is called, the given <i>widget</i> becomes the
current widget.</p>
<p><b>See also</b> <a href="qstackedlayout.html#insertWidget">insertWidget</a>(), <a href="qlayout.html#removeWidget">removeWidget</a>(), and <a href="qstackedlayout.html#setCurrentWidget">setCurrentWidget</a>().</p>
<h3 class="fn"><a name="count" />int QStackedLayout.count (<i>self</i>)</h3><h3 class="fn"><a name="currentIndex" />int QStackedLayout.currentIndex (<i>self</i>)</h3><h3 class="fn"><a name="currentWidget" /><a href="qwidget.html">QWidget</a> QStackedLayout.currentWidget (<i>self</i>)</h3><p>Returns the current widget, or 0 if there are no widgets in this
layout.</p>
<p><b>See also</b> <a href="qstackedlayout.html#currentIndex-prop">currentIndex</a>() and
<a href="qstackedlayout.html#setCurrentWidget">setCurrentWidget</a>().</p>
<h3 class="fn"><a name="insertWidget" />int QStackedLayout.insertWidget (<i>self</i>, int <i>index</i>, <a href="qwidget.html">QWidget</a> <i>w</i>)</h3><p>Inserts the given <i>widget</i> at the given <i>index</i> in
this <a href="qstackedlayout.html">QStackedLayout</a>. If
<i>index</i> is out of range, the widget is appended (in which case
it is the actual index of the <i>widget</i> that is returned).</p>
<p>If the <a href="qstackedlayout.html">QStackedLayout</a> is empty
before this function is called, the given <i>widget</i> becomes the
current widget.</p>
<p>Inserting a new widget at an index less than or equal to the
current index will increment the current index, but keep the
current widget.</p>
<p><b>See also</b> <a href="qstackedlayout.html#addWidget">addWidget</a>(), <a href="qlayout.html#removeWidget">removeWidget</a>(), and <a href="qstackedlayout.html#setCurrentWidget">setCurrentWidget</a>().</p>
<h3 class="fn"><a name="itemAt" /><a href="qlayoutitem.html">QLayoutItem</a> QStackedLayout.itemAt (<i>self</i>, int)</h3><p>Reimplemented from <a href="qlayout.html#itemAt">QLayout.itemAt</a>().</p>
<h3 class="fn"><a name="minimumSize" /><a href="qsize.html">QSize</a> QStackedLayout.minimumSize (<i>self</i>)</h3><p>Reimplemented from <a href="qlayoutitem.html#minimumSize">QLayoutItem.minimumSize</a>().</p>
<h3 class="fn"><a name="setCurrentIndex" />QStackedLayout.setCurrentIndex (<i>self</i>, int <i>index</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setCurrentIndex(int)</tt>.</p><h3 class="fn"><a name="setCurrentWidget" />QStackedLayout.setCurrentWidget (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>w</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void setCurrentWidget( ::QWidget*)</tt>.</p><p>Sets the current widget to be the specified <i>widget</i>. The
new current widget must already be contained in this stacked
layout.</p>
<p><b>See also</b> <a href="qstackedlayout.html#currentIndex-prop">setCurrentIndex</a>() and
<a href="qstackedlayout.html#currentWidget">currentWidget</a>().</p>
<h3 class="fn"><a name="setGeometry" />QStackedLayout.setGeometry (<i>self</i>, <a href="qrect.html">QRect</a> <i>rect</i>)</h3><p>Reimplemented from <a href="qlayoutitem.html#setGeometry">QLayoutItem.setGeometry</a>().</p>
<h3 class="fn"><a name="setStackingMode" />QStackedLayout.setStackingMode (<i>self</i>, <a href="qstackedlayout.html#StackingMode-enum">StackingMode</a> <i>stackingMode</i>)</h3><h3 class="fn"><a name="sizeHint" /><a href="qsize.html">QSize</a> QStackedLayout.sizeHint (<i>self</i>)</h3><p>Reimplemented from <a href="qlayoutitem.html#sizeHint">QLayoutItem.sizeHint</a>().</p>
<h3 class="fn"><a name="stackingMode" /><a href="qstackedlayout.html#StackingMode-enum">StackingMode</a> QStackedLayout.stackingMode (<i>self</i>)</h3><h3 class="fn"><a name="takeAt" /><a href="qlayoutitem.html">QLayoutItem</a> QStackedLayout.takeAt (<i>self</i>, int)</h3><p>The <i>QLayoutItem</i> result</p><p>Reimplemented from <a href="qlayout.html#takeAt">QLayout.takeAt</a>().</p>
<h3 class="fn"><a name="widget" /><a href="qwidget.html">QWidget</a> QStackedLayout.widget (<i>self</i>, int)</h3><p>Returns the widget at the given <i>index</i>, or 0 if there is
no widget at the given position.</p>
<p><b>See also</b> <a href="qstackedlayout.html#currentWidget">currentWidget</a>() and
<a href="qlayout.html#indexOf">indexOf</a>().</p>
<h3 class="fn"><a name="widget-2" /><a href="qwidget.html">QWidget</a> QStackedLayout.widget (<i>self</i>)</h3><hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="currentChanged" />void currentChanged (int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever the current widget in the layout
changes. The <i>index</i> specifies the index of the new current
widget, or -1 if there isn't a new one (for example, if there are
no widgets in the <a href="qstackedlayout.html">QStackedLayout</a>)</p>
<p><b>See also</b> <a href="qstackedlayout.html#currentWidget">currentWidget</a>() and
<a href="qstackedlayout.html#setCurrentWidget">setCurrentWidget</a>().</p>
<h3 class="fn"><a name="widgetRemoved" />void widgetRemoved (int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever a widget is removed from the
layout. The widget's <i>index</i> is passed as parameter.</p>
<p><b>See also</b> <a href="qlayout.html#removeWidget">removeWidget</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.12.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qt.io">The Qt Company</a> 2015</td><td align="right" width="25%">Qt 4.8.7</td></tr></table></div></address></body></html>
|