qgridlayout.html
来自「QT 下载资料仅供参考」· HTML 代码 · 共 386 行 · 第 1/2 页
HTML
386 行
<!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/qlayout.cpp:865 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QGridLayout 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>QGridLayout Class Reference</h1><p>The QGridLayout class lays out widgets in a grid.<a href="#details">More...</a><p><tt>#include <<a href="qlayout-h.html">qlayout.h</a>></tt><p>Inherits <a href="qlayout.html">QLayout</a>.<p><a href="qgridlayout-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QGridLayout"><b>QGridLayout</b></a> ( QWidget * parent, int nRows = 1, int nCols = 1, int margin = 0, int space = -1, const char * name = 0 )</div></li><li><div class=fn><a href="#QGridLayout-2"><b>QGridLayout</b></a> ( int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 )</div></li><li><div class=fn><a href="#QGridLayout-3"><b>QGridLayout</b></a> ( QLayout * parentLayout, int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 )</div></li><li><div class=fn><a href="#~QGridLayout"><b>~QGridLayout</b></a> ()</div></li><li><div class=fn>virtual QSize <a href="#sizeHint"><b>sizeHint</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="#setRowStretch"><b>setRowStretch</b></a> ( int row, int stretch )</div></li><li><div class=fn>virtual void <a href="#setColStretch"><b>setColStretch</b></a> ( int col, int stretch )</div></li><li><div class=fn>int <a href="#rowStretch"><b>rowStretch</b></a> ( int row ) const</div></li><li><div class=fn>int <a href="#colStretch"><b>colStretch</b></a> ( int col ) const</div></li><li><div class=fn>int <a href="#numRows"><b>numRows</b></a> () const</div></li><li><div class=fn>int <a href="#numCols"><b>numCols</b></a> () const</div></li><li><div class=fn>QRect <a href="#cellGeometry"><b>cellGeometry</b></a> ( int row, int col ) const</div></li><li><div class=fn>virtual bool <a href="#hasHeightForWidth"><b>hasHeightForWidth</b></a> () const</div></li><li><div class=fn>virtual int <a href="#heightForWidth"><b>heightForWidth</b></a> ( int w ) const</div></li><li><div class=fn>virtual QSizePolicy::ExpandData <a href="#expanding"><b>expanding</b></a> () const</div></li><li><div class=fn>virtual void <a href="#invalidate"><b>invalidate</b></a> ()</div></li><li><div class=fn>virtual void <a href="#addItem-2"><b>addItem</b></a> ( QLayoutItem * item )</div></li><li><div class=fn>void <a href="#addItem"><b>addItem</b></a> ( QLayoutItem * item, int row, int col )</div></li><li><div class=fn>void <a href="#addMultiCell"><b>addMultiCell</b></a> ( QLayoutItem * item, int fromRow, int toRow, int fromCol, int toCol, int alignment = 0 )</div></li><li><div class=fn>void <a href="#addWidget"><b>addWidget</b></a> ( QWidget * w, int row, int col, int alignment = 0 )</div></li><li><div class=fn>void <a href="#addMultiCellWidget"><b>addMultiCellWidget</b></a> ( QWidget * w, int fromRow, int toRow, int fromCol, int toCol, int alignment = 0 )</div></li><li><div class=fn>void <a href="#addLayout"><b>addLayout</b></a> ( QLayout * layout, int row, int col )</div></li><li><div class=fn>void <a href="#addMultiCellLayout"><b>addMultiCellLayout</b></a> ( QLayout * layout, int fromRow, int toRow, int fromCol, int toCol, int alignment = 0 )</div></li><li><div class=fn>void <a href="#addRowSpacing"><b>addRowSpacing</b></a> ( int row, int minsize )</div></li><li><div class=fn>void <a href="#addColSpacing"><b>addColSpacing</b></a> ( int col, int minsize )</div></li><li><div class=fn>void <a href="#expand"><b>expand</b></a> ( int nRows, int nCols )</div></li><li><div class=fn>enum <a href="#Corner-enum"><b>Corner</b></a> { TopLeft, TopRight, BottomLeft, BottomRight }</div></li><li><div class=fn>void <a href="#setOrigin"><b>setOrigin</b></a> ( Corner c )</div></li><li><div class=fn>Corner <a href="#origin"><b>origin</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setGeometry"><b>setGeometry</b></a> ( const QRect & r )</div></li></ul><h2>Protected Members</h2><ul><li><div class=fn>bool <a href="#findWidget"><b>findWidget</b></a> ( QWidget * w, int * row, int * col )</div></li><li><div class=fn>void <a href="#add"><b>add</b></a> ( QLayoutItem * item, int row, int col )</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2><p> The QGridLayout class lays out widgets in a grid.<p> <p> QGridLayout takes the space made available to it (by its parentlayout or by the <a href="qlayout.html#mainWidget">mainWidget</a>()), divides it up into rows andcolumns, and puts each widget it manages into the correct cell.<p> Columns and rows behave identically; we will discuss columns, butthere are equivalent functions for rows.<p> Each column has a minimum width and a <a href="layout.html#stretch-factor">stretch factor</a>. The minimumwidth is the greatest of that set using <a href="#addColSpacing">addColSpacing</a>() and theminimum width of each widget in that column. The stretch factor isset using <a href="#setColStretch">setColStretch</a>() and determines how much of the availablespace the column will get over and above its necessary minimum.<p> Normally, each managed widget or layout is put into a cell of itsown using <a href="#addWidget">addWidget</a>(), <a href="#addLayout">addLayout</a>() or by the <a href="qlayout.html#setAutoAdd">auto-add facility</a>. It is alsopossible for a widget to occupy multiple cells using<a href="#addMultiCellWidget">addMultiCellWidget</a>(). If you do this, QGridLayout will guess howto distribute the size over the columns/rows (based on the stretchfactors).<p> To remove a widget from a layout, either delete it or reparent itwith <a href="qwidget.html#reparent">QWidget::reparent</a>(). Hiding a widget with <a href="qwidget.html#hide">QWidget::hide</a>()also effectively removes the widget from the layout, until<a href="qwidget.html#show">QWidget::show</a>() is called.<p> This illustration shows a fragment of a dialog with a five-column,three-row grid (the grid is shown overlaid in magenta):<p> <center><img src="gridlayout.png"></center> <p> Columns 0, 2 and 4 in this dialog fragment are made up of a<a href="qlabel.html">QLabel</a>, a <a href="qlineedit.html">QLineEdit</a>, and a <a href="qlistbox.html">QListBox</a>. Columns 1 and 3 areplaceholders made with <a href="#addColSpacing">addColSpacing</a>(). Row 0 consists of threeQLabel objects, row 1 of three QLineEdit objects and row 2 ofthree QListBox objects. We used placeholder columns (1 and 3) toget the right amount of space between the columns.<p> Note that the columns and rows are not equally wide or tall. Ifyou want two columns to have the same width, you must set theirminimum widths and stretch factors to be the same yourself. You dothis using addColSpacing() and <a href="#setColStretch">setColStretch</a>().<p> If the QGridLayout is not the top-level layout (i.e. does notmanage all of the widget's area and children), you must add it toits parent layout when you create it, but before you do anythingwith it. The normal way to add a layout is by callingparentLayout->addLayout().<p> Once you have added your layout you can start putting widgets andother layouts into the cells of your grid layout using<a href="#addWidget">addWidget</a>(), <a href="#addLayout">addLayout</a>() and <a href="#addMultiCellWidget">addMultiCellWidget</a>().<p> QGridLayout also includes two margin widths: the border and thespacing. The border is the width of the reserved space along eachof the QGridLayout's four sides. The spacing is the width of theautomatically allocated spacing between neighboring boxes.<p> Both the border and the spacing are parameters of the constructorand default to 0.<p> <p>See also <a href="qgrid.html">QGrid</a>, <a href="layout.html">Layout Overview</a>, <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="Corner-enum"></a>QGridLayout::Corner</h3><p> This enum identifies which corner is the origin (0, 0) of thelayout.<ul><li><tt>QGridLayout::TopLeft</tt> - the top-left corner<li><tt>QGridLayout::TopRight</tt> - the top-right corner<li><tt>QGridLayout::BottomLeft</tt> - the bottom-left corner<li><tt>QGridLayout::BottomRight</tt> - the bottom-right corner</ul><hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QGridLayout"></a>QGridLayout::QGridLayout ( <a href="qwidget.html">QWidget</a> * parent, int nRows = 1, int nCols = 1, int margin = 0, int space = -1, const char * name = 0 )</h3>Constructs a new QGridLayout with <em>nRows</em> rows, <em>nCols</em> columnsand parent widget, <em>parent</em>. <em>parent</em> may not be 0. The gridlayout is called <em>name</em>.<p> <em>margin</em> is the number of pixels between the edge of the widgetand its managed children. <em>space</em> is the default number of pixelsbetween cells. If <em>space</em> is -1, the value of <em>margin</em> is used.<h3 class=fn><a name="QGridLayout-2"></a>QGridLayout::QGridLayout ( int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 )</h3>Constructs a new grid with <em>nRows</em> rows and <em>nCols</em> columns. If<em>spacing</em> is -1, this QGridLayout inherits its parent's<a href="qlayout.html#spacing">spacing</a>(); otherwise <em>spacing</em> is used. The grid layout is called<em>name</em>.<p> You must insert this grid into another layout. You can insertwidgets and layouts into this layout at any time, but laying outwill not be performed before this is inserted into another layout.<h3 class=fn><a name="QGridLayout-3"></a>QGridLayout::QGridLayout ( <a href="qlayout.html">QLayout</a> * parentLayout, int nRows = 1, int nCols = 1, int spacing = -1, const char * name = 0 )</h3>Constructs a new grid that is placed inside <em>parentLayout</em> with<em>nRows</em> rows and <em>nCols</em> columns. If <em>spacing</em> is -1, thisQGridLayout inherits its parent's <a href="qlayout.html#spacing">spacing</a>(); otherwise <em>spacing</em>is used. The grid layout is called <em>name</em>.<p> This grid is placed according to <em>parentLayout</em>'s defaultplacement rules.<h3 class=fn><a name="~QGridLayout"></a>QGridLayout::~QGridLayout ()</h3>Destroys the grid layout. Geometry management is terminated ifthis is a top-level grid.<p> The layout's widgets are <em>not</em> destroyed.<h3 class=fn>void <a name="add"></a>QGridLayout::add ( <a href="qlayoutitem.html">QLayoutItem</a> * item, int row, int col )<tt> [protected]</tt></h3>Adds <em>item</em> at position <em>row</em>, <em>col</em>. The layout takesownership of the <em>item</em>.<h3 class=fn>void <a name="addColSpacing"></a>QGridLayout::addColSpacing ( int col, int minsize )</h3>Sets the minimum width of column <em>col</em> to <em>minsize</em> pixels.<h3 class=fn>void <a name="addItem"></a>QGridLayout::addItem ( <a href="qlayoutitem.html">QLayoutItem</a> * item, int row, int col )</h3>Adds <em>item</em> at position <em>row</em>, <em>col</em>. The layout takesownership of the <em>item</em>.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?