📄 qboxlayout.3qt
字号:
.TH QBoxLayout 3qt "10 November 2000" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2000 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQBoxLayout \- Lines up child widgets horizontally or vertically.SH SYNOPSIS.br.PP\fC#include <qlayout.h>\fR.PPInherits QLayout..PPInherited by QHBoxLayout and QVBoxLayout..PP.SS "Public Members".in +1c.ti -1c.BI "enum \fBDirection\fR { LeftToRight, RightToLeft, TopToBottom, BottomToTop, Down = TopToBottom, Up = BottomToTop }".br.ti -1c.BI "\fBQBoxLayout\fR ( QWidget * " "parent" ", Direction, int " "border" "=0, int " "space" " = -1, const char * " "name" "=0 ) ".br.ti -1c.BI "\fBQBoxLayout\fR ( QLayout * " "parentLayout" ", Direction, int " "space" " = -1, const char * " "name" "=0 ) ".br.ti -1c.BI "\fBQBoxLayout\fR ( Direction, int " "space" " = -1, const char * " "name" "=0 ) ".br.ti -1c.BI "\fB~QBoxLayout\fR () ".br.ti -1c.BI "virtual void \fBaddItem\fR ( QLayoutItem * ) ".br.ti -1c.BI "Direction \fBdirection\fR () const".br.ti -1c.BI "void \fBsetDirection\fR ( Direction ) ".br.ti -1c.BI "void \fBaddSpacing\fR ( int size ) ".br.ti -1c.BI "void \fBaddStretch\fR ( int " "stretch" " = 0 ) ".br.ti -1c.BI "void \fBaddWidget\fR ( QWidget *, int " "stretch" " = 0, int " "alignment" " = 0 ) ".br.ti -1c.BI "void \fBaddLayout\fR ( QLayout * " "layout" ", int " "stretch" " = 0 ) ".br.ti -1c.BI "void \fBaddStrut\fR ( int ) ".br.ti -1c.BI "void \fBinsertSpacing\fR ( int " "index" ", int size ) ".br.ti -1c.BI "void \fBinsertStretch\fR ( int " "index" ", int " "stretch" " = 0 ) ".br.ti -1c.BI "void \fBinsertWidget\fR ( int " "index" ", QWidget * " "widget" ", int " "stretch" " = 0, int " "alignment" " = 0 ) ".br.ti -1c.BI "void \fBinsertLayout\fR ( int " "index" ", QLayout * " "layout" ", int " "stretch" " = 0 ) ".br.ti -1c.BI "bool \fBsetStretchFactor\fR ( QWidget *, int stretch ) ".br.ti -1c.BI "bool \fBsetStretchFactor\fR ( QLayout * " "l" ", int stretch ) ".br.ti -1c.BI "virtual QSize \fBsizeHint\fR () const".br.ti -1c.BI "virtual QSize \fBminimumSize\fR () const".br.ti -1c.BI "virtual QSize \fBmaximumSize\fR () const".br.ti -1c.BI "virtual bool \fBhasHeightForWidth\fR () const".br.ti -1c.BI "virtual int \fBheightForWidth\fR ( int ) const".br.ti -1c.BI "virtual QSizePolicy::ExpandData \fBexpanding\fR () const".br.ti -1c.BI "virtual void \fBinvalidate\fR () ".br.ti -1c.BI "virtual void \fBsetGeometry\fR ( const QRect & ) ".br.ti -1c.BI "int \fBfindWidget\fR ( QWidget * w ) ".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "void \fBinsertItem\fR ( int " "index" ", QLayoutItem * ) ".br.in -1c.SH DESCRIPTIONThe QBoxLayout class lines up child widgets horizontally or vertically..PPQBoxLayout takes the space it gets (from its parent layout or from the mainWidget()), divides it up into a row of boxes and makes each managed widget fill one box..PPIf the QBoxLayout is \fCHorizontal,\fR the boxes are beside each other, with suitable sizes. Each widget (or other box) will get at least its minimum sizes and at most its maximum size, and any excess space is shared according to the stretch factors (more about that below)..PPIf the QBoxLayout is \fCVertical,\fR the boxes are above and below each other, again with suitable sizes..PPThe easiest way to create a QBoxLayout is to use one of the convenience classes QHBoxLayout (for \fCHorizontal\fR boxes) or QVBoxLayout (for \fCVertical\fR boxes). You can also use the QBoxLayout constructor directly, specifying its direction as \fCLeftToRight, Down, RightToLeft\fR or \fCUp.\fR.PPIf the QBoxLayout is not the top-level layout (ie. is not managing all of the widget's area and children), you must add it to its parent layout before you can do anything with it. The normal way to add a layout is by calling parentLayout->addLayout()..PPOnce you have done that, you can add boxes to the QBoxLayout using one of four functions: .TPaddWidget() to add a widget to the QBoxLayout and set the widget's stretch factor. (The stretch factor is along the row of boxes.).TPaddSpacing() to create an empty box; this is one of the functions you use to create nice and spacious dialogs. See below for ways to set margins..TPaddStretch() to create an empty, stretchable box..TPaddLayout() to add a box containing another QLayout to the row and set that layout's stretch factor..IP.PPUse insertWidget(), insertSpacing(), insertStretch() or insertLayout() to insert a box at a specified position in the layout..PPQBoxLayout also includes two margin widths: .TPsetMargin() sets the width of the outer border. This is the width of the reserved space along each of the QBoxLayout's four sides..TPsetSpacing() sets the inter-box width. This is the width of the automatically allocated spacing between neighbouring boxes. (You can use addSpacing() to get more space at a .).IP.PPThe outer border width defaults to 0, and the intra-widget width defaults to the same as the border width for a top-level layout, or to the same as the parent layout otherwise. Both can be set using arguments to the constructor..PPYou will almost always want to use the convenience classes for QBoxLayout: QVBoxLayout and QHBoxLayout, because of their simpler constructors..PPSee also the Layout overview documentation.PPExamples:.(llayout/layout.cpp popup/popup.cpp customlayout/main.cpp.)l.SS "Member Type Documentation".SH "QBoxLayout::Direction"This type is used to determine the direction of a box layout. The possible values are:.TP\fCLeftToRight\fR - Horizontal, from left to right.TP\fCRightToLeft\fR - Horizontal, from right to left.TP\fCTopToBottom\fR - Vertical, from top to bottom.TP\fCDown\fR - An alias for \fCTopToBottom\fR.TP\fCBottomToTop\fR - Vertical, from bottom to top.TP\fCUp\fR - An alias for \fCBottomToTop\fR.SH MEMBER FUNCTION DOCUMENTATION.SH "QBoxLayout::QBoxLayout ( Direction d, int space = -1, const char * name=0 )"If \fIspace\fR is -1, this QBoxLayout will inherit its parent's spacing(), otherwise \fIspace\fR is used..PPYou have to insert this box into another layout..PPExamples:.(llayout/layout.cpp.)l.SH "QBoxLayout::QBoxLayout ( QLayout * parentLayout, Direction d, int space = -1, const char * name=0 )"Constructs a new QBoxLayout with direction \fId\fR and inserts it into \fIparentLayout.\fR.SH "QBoxLayout::QBoxLayout ( QWidget * parent, Direction d, int border=0, int space = -1, const char * name=0 )"Constructs a new QBoxLayout with direction \fId\fR and main widget \fIparent. parent\fR may not be 0..PP\fIborder\fR is the number of pixels between the edge of the widget and the managed children. \fIspace\fR is the default number of pixels between neighbouring children. If \fIspace\fR is -1 the value of \fIborder\fR is used..PP\fIname\fR is the internal object name.PPSee also direction()..SH "QBoxLayout::~QBoxLayout ()"Destructs this box..SH "void QBoxLayout::addItem ( QLayoutItem * item ) \fC[virtual]\fR"Adds \fIitem\fR to the end of this box layout..PPReimplemented from QLayout..SH "void QBoxLayout::addLayout ( QLayout * layout, int stretch = 0 )"Adds \fIlayout\fR to the end of the box, with serial stretch factor \fIstretch.\fR.PPSee also insertLayout(), setAutoAdd(), addWidget() and addSpacing()..SH "void QBoxLayout::addSpacing ( int size )"Adds a non-stretchable space with size \fIsize\fR to the end of this box layout. QBoxLayout gives default border and spacing. This function adds additional space..PPSee also insertSpacing() and addStretch()..SH "void QBoxLayout::addStretch ( int stretch = 0 )"Adds a stretchable space with zero minimum size and stretch factor \fIstretch\fR to the end of this box layout..PPSee also addSpacing()..SH "void QBoxLayout::addStrut ( int size )"Limits the perpendicular dimension of the box (e.g. height if the box is LeftToRight) to a minimum of \fIsize.\fR Other constraints may increase the limit..SH "void QBoxLayout::addWidget ( QWidget * widget, int stretch = 0, int alignment = 0 )"Adds \fIwidget\fR to the end of this box layout, with a stretch factor \fIstretch\fR and alignment \fIalignment.\fR.PPThe stretch factor applies only in the direction of the QBoxLayout, and is relative to the other boxes and widgets in this QBoxLayout. Widgets and boxes with higher stretch factor grow more..PPIf the stretch factor is 0 and nothing else in the QBoxLayout has a stretch factor greater than zero, the space is distributed according to the QWidget:sizePolicy() of each widget that's involved..PPAlignment is specified by \fIalignment\fR which is a bitwise OR of Qt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell..PPNote: The alignment parameter is interpreted more aggressively than in previous versions of Qt. A non-default alignment now indicates that the widget should not grow to fill the available space, but should be sized according to sizeHint()..PPSee also insertWidget(), setAutoAdd(), addLayout() and addSpacing()..PPExamples:.(llayout/layout.cpp popup/popup.cpp scrollview/scrollview.cpp customlayout/main.cpp.)l.SH "QBoxLayout::Direction QBoxLayout::direction() const"Returns the (serial) direction of the box. addWidget() and addSpacing() work in this direction; the stretch stretches in this direction..PPThe directions are \fCLeftToRight, RightToLeft, TopToBottom\fR and \fCBottomToTop.\fR For the last two, the shorter aliases \fCDown\fR and \fCUp\fR are also available..PPSee also addWidget() and addSpacing()..SH "QSizePolicy::ExpandData QBoxLayout::expanding() const \fC[virtual]\fR"Returns the expansiveness of this layout..PPReimplemented from QLayoutItem..SH "int QBoxLayout::findWidget ( QWidget * w )"Searches for \fIw\fR in this layout (not including child layouts)..PPReturns the index of \fIw,\fR or -1 if \fIw\fR is not found..SH "bool QBoxLayout::hasHeightForWidth () const \fC[virtual]\fR"Returns whether this layout's preferred height depends on its width..PPReimplemented from QLayoutItem..SH "int QBoxLayout::heightForWidth ( int w ) const \fC[virtual]\fR"Returns the layout's preferred height when it is \fIw\fR pixels wide..PPReimplemented from QLayoutItem..SH "void QBoxLayout::insertItem ( int index, QLayoutItem * item ) \fC[protected]\fR"Inserts \fIitem\fR in this box layout at index \fIindex.\fR If \fIindex\fR is negative, the item is added at the end..PP\fBWarning:\fR does not call QLayout::insertChildLayout() if \fIitem\fR is a QLayout..PPSee also addItem() and findWidget()..SH "void QBoxLayout::insertLayout ( int index, QLayout * layout, int stretch = 0 )"Inserts \fIlayout\fR at index \fIindex,\fR with serial stretch factor \fIstretch.\fR If \fIindex\fR is negative, the layout is added at the end..PPSee also setAutoAdd(), insertWidget() and insertSpacing()..SH "void QBoxLayout::insertSpacing ( int index, int size )"Inserts a non-stretchable space at index \fIindex\fR with size \fIsize.\fR If \fIindex\fR is negative, the space is added at the end..PPQBoxLayout gives default border and spacing. This function adds additional space..PPSee also insertStretch()..SH "void QBoxLayout::insertStretch ( int index, int stretch = 0 )"Inserts a stretchable space at index \fIindex\fR with zero minimum size and stretch factor \fIstretch.\fR If \fIindex\fR is negative, the space is added at the end..PPSee also insertSpacing()..SH "void QBoxLayout::insertWidget ( int index, QWidget * widget, int stretch = 0, int alignment = 0 )"Inserts \fIwidget\fR at index \fIindex,\fR with a \fIstretch\fR factor and \fIalignment.\fR If \fIindex\fR is negative, the widget is added at the end..PPThe stretch factor applies only in the direction of the QBoxLayout, and is relative to the other boxes and widgets in this QBoxLayout. Widgets and boxes with higher stretch factor grow more..PPIf the stretch factor is 0 and nothing else in the QBoxLayout has a stretch factor greater than zero, the space is distributed according to the QWidget:sizePolicy() of each widget that's involved..PPAlignment is specified by \fIalignment\fR which is a bitwise OR of Qt::AlignmentFlags values. The default alignment is 0, which means that the widget fills the entire cell..PPNote: The alignment parameter is interpreted more aggressively than in previous versions of Qt. A non-default alignment now indicates that the widget should not grow to fill the available space, but should be sized according to sizeHint()..PPSee also setAutoAdd(), insertLayout() and insertSpacing()..SH "void QBoxLayout::invalidate () \fC[virtual]\fR"Resets cached information..PPReimplemented from QLayoutItem..SH "QLayoutIterator QBoxLayout::iterator () \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QLayoutItem..SH "QSize QBoxLayout::maximumSize () const \fC[virtual]\fR"Returns the maximum size needed by this box..PPReimplemented from QLayoutItem..SH "QSize QBoxLayout::minimumSize () const \fC[virtual]\fR"Returns the minimum size needed by this box..PPReimplemented from QLayoutItem..SH "void QBoxLayout::setDirection ( Direction direction )"Sets the direction of this layout to \fIdirection.\fR.SH "void QBoxLayout::setGeometry ( const QRect & r ) \fC[virtual]\fR"Resizes managed widgets within the rectangle \fIr.\fR.PPReimplemented from QLayoutItem..SH "bool QBoxLayout::setStretchFactor ( QLayout * l, int stretch )"Sets the stretch factor for the layout \fIl\fR to \fIstretch\fR and returns TRUE, if \fIl\fR is found in this layout (not including child layouts)..PPReturns FALSE if \fIl\fR is not found..SH "bool QBoxLayout::setStretchFactor ( QWidget * w, int stretch )"Sets the stretch factor for widget \fIw\fR to \fIstretch\fR and returns TRUE, if \fIw\fR is found in this layout (not including child layouts)..PPReturns FALSE if \fIw\fR is not found..SH "QSize QBoxLayout::sizeHint () const \fC[virtual]\fR"Returns the preferred size of this grid..PPReimplemented from QLayoutItem..SH "SEE ALSO".BR http://doc.trolltech.com/qboxlayout.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -