📄 qlayout.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/kernel/qabstractlayout.cpp:595 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QLayout Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td 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="mainclasses.html"><font color="#004faf">Main Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QLayout Class Reference</h1><p>The QLayout class is the base class of geometry managers.<a href="#details">More...</a><p><tt>#include <<a href="qlayout-h.html">qlayout.h</a>></tt><p>Inherits <a href="qobject.html">QObject</a> and <a href="qlayoutitem.html">QLayoutItem</a>.<p>Inherited by <a href="qgridlayout.html">QGridLayout</a> and <a href="qboxlayout.html">QBoxLayout</a>.<p><a href="qlayout-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QLayout"><b>QLayout</b></a> ( QWidget * parent, int margin = 0, int spacing = -1, const char * name = 0 )</div></li><li><div class=fn><a href="#QLayout-2"><b>QLayout</b></a> ( QLayout * parentLayout, int spacing = -1, const char * name = 0 )</div></li><li><div class=fn><a href="#QLayout-3"><b>QLayout</b></a> ( int spacing = -1, const char * name = 0 )</div></li><li><div class=fn>int <a href="#margin"><b>margin</b></a> () const</div></li><li><div class=fn>int <a href="#spacing"><b>spacing</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setMargin"><b>setMargin</b></a> ( int )</div></li><li><div class=fn>virtual void <a href="#setSpacing"><b>setSpacing</b></a> ( int )</div></li><li><div class=fn>enum <a href="#ResizeMode-enum"><b>ResizeMode</b></a> { FreeResize, Minimum, Fixed }</div></li><li><div class=fn>void <a href="#setResizeMode"><b>setResizeMode</b></a> ( ResizeMode )</div></li><li><div class=fn>ResizeMode <a href="#resizeMode"><b>resizeMode</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setMenuBar"><b>setMenuBar</b></a> ( QMenuBar * w )</div></li><li><div class=fn>QMenuBar * <a href="#menuBar"><b>menuBar</b></a> () const</div></li><li><div class=fn>QWidget * <a href="#mainWidget"><b>mainWidget</b></a> ()</div></li><li><div class=fn>bool <a href="#isTopLevel"><b>isTopLevel</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setAutoAdd"><b>setAutoAdd</b></a> ( bool b )</div></li><li><div class=fn>bool <a href="#autoAdd"><b>autoAdd</b></a> () const</div></li><li><div class=fn>virtual void <a href="#invalidate"><b>invalidate</b></a> ()</div></li><li><div class=fn>bool <a href="#activate"><b>activate</b></a> ()</div></li><li><div class=fn>void <a href="#add"><b>add</b></a> ( QWidget * w )</div></li><li><div class=fn>virtual void <a href="#addItem"><b>addItem</b></a> ( QLayoutItem * item ) = 0</div></li><li><div class=fn>virtual QSizePolicy::ExpandData <a href="#expanding"><b>expanding</b></a> () const</div></li><li><div class=fn>virtual QSize <a href="#minimumSize"><b>minimumSize</b></a> () const</div></li><li><div class=fn>virtual QSize <a href="#maximumSize"><b>maximumSize</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setGeometry"><b>setGeometry</b></a> ( const QRect & r ) = 0</div></li><li><div class=fn>virtual QLayoutIterator <a href="#iterator"><b>iterator</b></a> () = 0</div></li><li><div class=fn>virtual bool <a href="#isEmpty"><b>isEmpty</b></a> () const</div></li><li><div class=fn>bool <a href="#supportsMargin"><b>supportsMargin</b></a> () const</div></li><li><div class=fn>void <a href="#setEnabled"><b>setEnabled</b></a> ( bool enable )</div></li><li><div class=fn>bool <a href="#isEnabled"><b>isEnabled</b></a> () const</div></li></ul><h2>Properties</h2><ul><li><div class=fn>int <a href="#margin-prop"><b>margin</b></a> - the width of the outside border of the layout</div></li><li><div class=fn>ResizeMode <a href="#resizeMode-prop"><b>resizeMode</b></a> - the resize mode of the layout</div></li><li><div class=fn>int <a href="#spacing-prop"><b>spacing</b></a> - the spacing between widgets inside the layout</div></li></ul><h2>Protected Members</h2><ul><li><div class=fn>void <a href="#addChildLayout"><b>addChildLayout</b></a> ( QLayout * l )</div></li><li><div class=fn>void <a href="#deleteAllItems"><b>deleteAllItems</b></a> ()</div></li><li><div class=fn>void <a href="#setSupportsMargin"><b>setSupportsMargin</b></a> ( bool b )</div></li><li><div class=fn>QRect <a href="#alignmentRect"><b>alignmentRect</b></a> ( const QRect & r ) const</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QLayout class is the base class of geometry managers.<p> <p> This is an abstract base class inherited by the concrete classes,<a href="qboxlayout.html">QBoxLayout</a> and <a href="qgridlayout.html">QGridLayout</a>.<p> For users of QLayout subclasses or of <a href="qmainwindow.html">QMainWindow</a> there is seldomany need to use the basic functions provided by QLayout, such as<a href="#resizeMode-prop">resizeMode</a> or <a href="#setMenuBar">setMenuBar</a>(). See the <a href="layout.html">layout overview page</a> for more information.<p> To make your own layout manager, subclass <a href="qglayoutiterator.html">QGLayoutIterator</a> andimplement the functions <a href="#addItem">addItem</a>(), <a href="qlayoutitem.html#sizeHint">sizeHint</a>(), <a href="#setGeometry">setGeometry</a>(), and<a href="#iterator">iterator</a>(). You should also implement <a href="#minimumSize">minimumSize</a>() to ensure yourlayout isn't resized to zero size if there is too little space. Tosupport children whose heights depend on their widths, implement<a href="qlayoutitem.html#hasHeightForWidth">hasHeightForWidth</a>() and <a href="qlayoutitem.html#heightForWidth">heightForWidth</a>(). See the <a href="customlayout.html">custom layout page</a> for an in-depthdescription.<p> Geometry management stops when the layout manager is deleted.<p>See also <a href="appearance.html">Widget Appearance and Style</a> and <a href="geomanagement.html">Layout Management</a>.<hr><h2>Member Type Documentation</h2><h3 class=fn><a name="ResizeMode-enum"></a>QLayout::ResizeMode</h3><p> The possible values are:<ul><li><tt>QLayout::Fixed</tt> - The main widget's size is set to <a href="qlayoutitem.html#sizeHint">sizeHint</a>(); itcannot be resized at all.<li><tt>QLayout::Minimum</tt> - The main widget's minimum size is set to<a href="#minimumSize">minimumSize</a>(); it cannot be smaller.<li><tt>QLayout::FreeResize</tt> - The widget is not constrained.</ul><hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QLayout"></a>QLayout::QLayout ( <a href="qwidget.html">QWidget</a> * parent, int margin = 0, int spacing = -1, const char * name = 0 )</h3>Constructs a new top-level QLayout called <em>name</em>, with mainwidget <em>parent</em>. <em>parent</em> may not be 0.<p> The <em>margin</em> is the number of pixels between the edge of thewidget and the managed children. The <em>spacing</em> sets the value of<a href="#spacing">spacing</a>(), which gives the spacing between the managed widgets. If<em>spacing</em> is -1 (the default), spacing is set to the value of <em>margin</em>.<p> There can be only one top-level layout for a widget. It isreturned by <a href="qwidget.html#layout">QWidget::layout</a>()<h3 class=fn><a name="QLayout-2"></a>QLayout::QLayout ( <a href="qlayout.html">QLayout</a> * parentLayout, int spacing = -1, const char * name = 0 )</h3>Constructs a new child QLayout called <em>name</em>, and places itinside <em>parentLayout</em> by using the default placement defined by<a href="#addItem">addItem</a>().<p> If <em>spacing</em> is -1, this QLayout inherits <em>parentLayout</em>'s<a href="#spacing">spacing</a>(), otherwise the value of <em>spacing</em> is used.<h3 class=fn><a name="QLayout-3"></a>QLayout::QLayout ( int spacing = -1, const char * name = 0 )</h3>Constructs a new child QLayout called <em>name</em>. If <em>spacing</em> is-1, this QLayout inherits its parent's <a href="#spacing">spacing</a>(); otherwise thevalue of <em>spacing</em> is used.<p> This layout has to be inserted into another layout before geometrymanagement will work.<h3 class=fn>bool <a name="activate"></a>QLayout::activate ()</h3>Redoes the layout for <a href="#mainWidget">mainWidget</a>(). You should generally not needto call this because it is automatically called at the mostappropriate times.<p> However, if you set up a QLayout for a visible widget withoutresizing that widget, you will need to call this function in orderto lay it out.<p> <p>See also <a href="qwidget.html#updateGeometry">QWidget::updateGeometry</a>().<p>Examples: <a href="layout-example.html#x489">layout/layout.cpp</a>, <a href="popup-example.html#x1575">popup/popup.cpp</a>, <a href="scrollview-example.html#x717">scrollview/scrollview.cpp</a> and <a href="sql.html#x2221">sql/overview/form1/main.cpp</a>.<h3 class=fn>void <a name="add"></a>QLayout::add ( <a href="qwidget.html">QWidget</a> * w )</h3><p> Adds widget <em>w</em> to this layout in a manner specific to thelayout. This function uses <a href="#addItem">addItem</a>().<p>Examples: <a href="customlayout-example.html#x1360">customlayout/border.cpp</a> and <a href="customlayout-example.html#x1407">customlayout/main.cpp</a>.<h3 class=fn>void <a name="addChildLayout"></a>QLayout::addChildLayout ( <a href="qlayout.html">QLayout</a> * l )<tt> [protected]</tt></h3>This function is called from addLayout() functions in subclassesto add layout <em>l</em> as a sub-layout.<h3 class=fn>void <a name="addItem"></a>QLayout::addItem ( <a href="qlayoutitem.html">QLayoutItem</a> * item )<tt> [pure virtual]</tt></h3><p> Implemented in subclasses to add an <em>item</em>. How it is added isspecific to each subclass.<p> The ownership of <em>item</em> is transferred to the layout, and it'sthe layout's responsibility to delete it.<p>Examples: <a href="customlayout-example.html#x1361">customlayout/border.cpp</a>, <a href="customlayout-example.html#x1382">customlayout/card.cpp</a> and <a href="customlayout-example.html#x1338">customlayout/flow.cpp</a>.<p>Reimplemented in <a href="qgridlayout.html#addItem-2">QGridLayout</a> and <a href="qboxlayout.html#addItem">QBoxLayout</a>.<h3 class=fn><a href="qrect.html">QRect</a> <a name="alignmentRect"></a>QLayout::alignmentRect ( const <a href="qrect.html">QRect</a> & r ) const<tt> [protected]</tt></h3>Returns the rectangle that should be covered when the geometry ofthis layout is set to <em>r</em>, provided that this layout supports<a href="qlayoutitem.html#setAlignment">setAlignment</a>().<p> The result is derived from <a href="qlayoutitem.html#sizeHint">sizeHint</a>() and <a href="#expanding">expanding</a>(). It is neverlarger than <em>r</em>.<h3 class=fn>bool <a name="autoAdd"></a>QLayout::autoAdd () const</h3><p> Returns TRUE if this layout automatically grabs all new<a href="#mainWidget">mainWidget</a>()'s new children and adds them as defined by <a href="#addItem">addItem</a>();otherwise returns FALSE. This has effect only for top-levellayouts, i.e. layouts that are direct children of theirmainWidget().<p> <a href="#autoAdd">autoAdd</a>() is disabled by default.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -