142 void effectiveMargins(
int *
left,
int *top,
int *
right,
int *bottom)
const;
164 int b = bottomMargin;
172 leftBox = list.value(0);
173 rightBox = list.value(list.count() - 1);
175 qSwap(leftBox, rightBox);
182 leftDelta = itm->
geometry().
left() - w->geometry().left();
192 qSwap(leftDelta, rightDelta);
194 l =
qMax(l, leftDelta);
195 r =
qMax(r, rightDelta);
198 int count = top || bottom ? list.count() : 0;
199 for (
int i = 0; i < count; ++i) {
217 topBox = list.value(0);
218 bottomBox = list.value(list.count() - 1);
220 qSwap(topBox, bottomBox);
230 if (bottom && bottomBox) {
238 int count = left || right ? list.count() : 0;
239 for (
int i = 0; i < count; ++i) {
287 int n = list.count();
291 QSizePolicy::ControlTypes controlTypes1;
292 QSizePolicy::ControlTypes controlTypes2;
293 int fixedSpacing = q->spacing();
294 int previousNonEmptyIndex = -1;
297 if (fixedSpacing < 0) {
302 for (
int i = 0; i < n; i++) {
312 if (fixedSpacing >= 0) {
313 spacing = (previousNonEmptyIndex >= 0) ? fixedSpacing : 0;
315 if (!
horz(dir) && previousNonEmptyIndex >= 0) {
325 controlTypes1 = controlTypes2;
327 if (previousNonEmptyIndex >= 0) {
328 QSizePolicy::ControlTypes actual1 = controlTypes1;
329 QSizePolicy::ControlTypes actual2 = controlTypes2;
331 qSwap(actual1, actual2);
336 0, q->parentWidget());
343 if (previousNonEmptyIndex >= 0)
344 a[previousNonEmptyIndex].spacing = spacing;
345 previousNonEmptyIndex = i;
352 horexp = horexp || expand;
353 maxw += spacing + max.
width();
354 minw += spacing + min.
width();
355 hintw += spacing + hint.
width();
362 a[i].sizeHint = hint.
width();
363 a[i].maximumSize = max.
width();
364 a[i].minimumSize = min.
width();
365 a[i].expansive = expand;
369 verexp = verexp || expand;
370 maxh += spacing + max.
height();
371 minh += spacing + min.
height();
372 hinth += spacing + hint.
height();
379 a[i].sizeHint = hint.
height();
380 a[i].maximumSize = max.
height();
381 a[i].minimumSize = min.
height();
382 a[i].expansive = expand;
393 expanding = (Qt::Orientations)
397 minSize =
QSize(minw, minh);
401 q->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
403 effectiveMargins(&left, &top, &right, &bottom);
404 QSize extra(left + right, top + bottom);
427 for (
int i = 0; i < n; i++) {
433 for (
int i = 0; i < n; ++i) {
624 #endif // QT3_SUPPORT 652 if (
d->spacing >=0) {
681 const_cast<QBoxLayout*
>(
this)->d_func()->setupGeom();
692 const_cast<QBoxLayout*
>(
this)->d_func()->setupGeom();
703 const_cast<QBoxLayout*
>(
this)->d_func()->setupGeom();
721 const_cast<QBoxLayout*
>(
this)->d_func()->setupGeom();
735 d->effectiveMargins(&left, &top, &right, &bottom);
738 if (w !=
d->hfwWidth)
739 const_cast<QBoxLayout*
>(
this)->d_func()->calcHfw(w);
741 return d->hfwHeight + top + bottom;
752 d->effectiveMargins(0, &top, 0, &bottom);
753 return d->hasHfw ? (
d->hfwMinHeight + top + bottom) : -1;
772 return d->list.count();
781 return index >= 0 && index <
d->list.count() ?
d->list.at(index)->item : 0;
790 if (index < 0 || index >=
d->list.count())
815 const_cast<QBoxLayout*
>(
this)->d_func()->setupGeom();
833 d->effectiveMargins(&left, &top, &right, &bottom);
836 cr.
height() - (top + bottom));
839 int pos =
horz(
d->dir) ? s.
x() : s.
y();
842 if (
d->hasHfw && !
horz(
d->dir)) {
843 for (
int i = 0; i < n; i++) {
847 a[i].sizeHint = a[i].minimumSize =
867 for (
int j = 0; j < n; j++) {
868 int i = reverse ? n-j-1 : j;
913 index =
d->list.count();
916 d->list.insert(index, it);
933 index =
d->list.count();
944 d->list.insert(index, it);
964 index =
d->list.count();
974 d->list.insert(index, it);
994 index =
d->list.count();
998 d->list.insert(index, it);
1016 index =
d->list.count();
1018 d->list.insert(index, it);
1050 index =
d->list.count();
1063 d->list.insert(index, it);
1185 for (
int i = 0; i <
d->list.size(); ++i) {
1209 for (
int i = 0; i <
d->list.size(); ++i) {
1212 if (box->
stretch != stretch) {
1231 if (index >= 0 && index < d->list.size()) {
1233 if (box->
stretch != stretch) {
1249 if (index >= 0 && index < d->list.size())
1250 return d->list.at(index)->stretch;
1260 if (
d->dir == direction)
1267 for (
int i = 0; i <
d->list.size(); ++i) {
1281 if (
horz(direction))
QVBoxLayout()
Constructs a new vertical box.
static Qt::LayoutDirection layoutDirection()
void effectiveMargins(int *left, int *top, int *right, int *bottom) const
QLayoutItem * itemAt(int) const
Reimplemented Function
QSize sizeHint() const
Reimplemented Function
The QBoxLayout class lines up child widgets horizontally or vertically.
#define QT_END_NAMESPACE
This macro expands to.
QHBoxLayout()
Constructs a new horizontal box.
QPointer< QWidget > widget
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
virtual QRect geometry() const =0
Returns the rectangle covered by this layout item.
char * data()
Returns a pointer to the data stored in the byte array.
Qt::Orientations expandingDirections() const
Reimplemented Function
#define it(className, varName)
QBoxLayoutItem(QLayoutItem *it, int stretch_=0)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
QList< QBoxLayoutItem * > list
virtual bool isEmpty() const =0
Implemented in subclasses to return whether this item is empty, i.
~QBoxLayout()
Destroys this box layout.
QVector< QLayoutStruct > geomArray
static C reverse(const C &l)
void addLayout(QLayout *layout, int stretch=0)
Adds layout to the end of the box, with serial stretch factor stretch.
virtual void addItem(QLayoutItem *)=0
Implemented in subclasses to add an item.
virtual Qt::Orientations expandingDirections() const =0
Returns whether this layout item can make use of more space than sizeHint().
QSizePolicy::ControlTypes controlTypes() const
Returns the control type(s) for the layout item.
QSize expandedTo(const QSize &) const
Returns a size holding the maximum width and height of this size and the given otherSize.
void insertStretch(int index, int stretch=0)
Inserts a stretchable space (a QSpacerItem) at position index, with zero minimum size and stretch fac...
int left() const
Returns the x-coordinate of the rectangle's left edge.
static bool ignore(const char *test, const char *const *table)
void insertSpacing(int index, int size)
Inserts a non-stretchable space (a QSpacerItem) at position index, with size size.
~QVBoxLayout()
Destroys this box layout.
int width() const
Returns the width of the rectangle.
Qt::Orientations expanding
QSize minimumSize() const
Reimplemented Function
void addSpacerItem(QSpacerItem *spacerItem)
Adds spacerItem to the end of this box layout.
virtual void setGeometry(const QRect &)
Reimplemented Function
long ASN1_INTEGER_get ASN1_INTEGER * a
void invalidate()
Reimplemented Function
int height() const
Returns the height of the rectangle.
virtual QSize minimumSize() const =0
Implemented in subclasses to return the minimum size of this item.
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
void setHeight(int h)
Sets the height to the given height.
virtual bool hasHeightForWidth() const
Returns true if this layout's preferred height depends on its width; otherwise returns false...
bool empty() const
This function is provided for STL compatibility.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
QSize boundedTo(const QSize &) const
Returns a size holding the minimum width and height of this size and the given otherSize.
int horizontalStretch() const
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
void addItem(QLayoutItem *)
Reimplemented Function
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void setParent(QObject *)
Makes the object a child of parent.
virtual QSpacerItem * spacerItem()
If this item is a QSpacerItem, it is returned as a QSpacerItem; otherwise 0 is returned.
void setStretch(int index, int stretch)
Sets the stretch factor at position index.
void setObjectName(const QString &name)
void invalidate()
Resets cached information.
void setWidth(int w)
Sets the width to the given width.
QWidget * parentWidget() const
Returns the parent widget of this layout, or 0 if this layout is not installed on any widget...
void addStretch(int stretch=0)
Adds a stretchable space (a QSpacerItem) with zero minimum size and stretch factor stretch to the end...
void setDirection(Direction)
Sets the direction of this layout to direction.
int width() const
Returns the width.
void setAlignment(Qt::Alignment a)
Sets the alignment of this item to alignment.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Direction
This type is used to determine the direction of a box layout.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
QLayout()
Constructs a new child QLayout.
bool adoptLayout(QLayout *layout)
The QSpacerItem class provides blank space in a layout.
Qt::Orientations expandingDirections() const
Reimplemented Function
T takeFirst()
Removes the first item in the list and returns it.
void insertWidget(int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=0)
Inserts widget at position index, with stretch factor stretch and alignment alignment.
int count() const
Reimplemented Function
void insertLayout(int index, QLayout *layout, int stretch=0)
Inserts layout at position index, with stretch factor stretch.
The QLayout class is the base class of geometry managers.
int minimumHeightForWidth(int) const
Reimplemented Function
static bool checkWidget(QLayout *layout, QWidget *widget)
~QHBoxLayout()
Destroys this box layout.
Q_CORE_EXPORT void qWarning(const char *,...)
int verticalStretch() const
void addStrut(int)
Limits the perpendicular dimension of the box (e.g.
static bool horz(QBoxLayout::Direction dir)
static QSpacerItem * createSpacerItem(const QLayout *layout, int w, int h, QSizePolicy::Policy hPolicy=QSizePolicy::Minimum, QSizePolicy::Policy vPolicy=QSizePolicy::Minimum)
Direction direction() const
Returns the direction of the box.
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
bool setStretchFactor(QWidget *w, int stretch)
Sets the stretch factor for widget to stretch and returns true if widget is found in this layout (not...
QBoxLayout::Direction dir
QRect alignmentRect(const QRect &) const
Returns the rectangle that should be covered when the geometry of this layout is set to r...
void qSwap(T &value1, T &value2)
const T & at(int i) const
Returns the item at index position i in the vector.
static QWidget * parentWidget(const QWidget *w)
virtual void setGeometry(const QRect &)=0
Implemented in subclasses to set this item's geometry to r.
void qGeomCalc(QVector< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
static QWidgetItem * createWidgetItem(const QLayout *layout, QWidget *widget)
int top() const
Returns the y-coordinate of the rectangle's top edge.
Q_GUI_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm)
QLayoutItem * takeAt(int)
Reimplemented Function
#define Q_DECLARE_PUBLIC(Class)
int right() const
Returns the x-coordinate of the rectangle's right edge.
int y() const
Returns the y-coordinate of the rectangle's top edge.
void addChildWidget(QWidget *w)
This function is called from addWidget() functions in subclasses to add w as a managed widget of a la...
virtual QSize sizeHint() const =0
Implemented in subclasses to return the preferred size of this item.
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise 0 is returned.
QSize maximumSize() const
Reimplemented Function
void addSpacing(int size)
Adds a non-stretchable space (a QSpacerItem) with size size to the end of this box layout...
void setSpacing(int spacing)
Reimplements QLayout::setSpacing().
int x() const
Returns the x-coordinate of the rectangle's left edge.
QObject * parent() const
Returns a pointer to the parent object.
virtual QSize maximumSize() const =0
Implemented in subclasses to return the maximum size of this item.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
QString objectName() const
int height() const
Returns the height.
The QRect class defines a rectangle in the plane using integer precision.
void insertItem(int index, QLayoutItem *)
Inserts item into this box layout at position index.
void setGeometry(const QRect &)
Reimplemented Function
Qt::Alignment alignment() const
Returns the alignment of this item.
QBoxLayout(Direction, QWidget *parent=0)
Constructs a new QBoxLayout with direction dir and parent widget parent.
int spacing() const
Reimplements QLayout::spacing().
virtual QWidget * widget()
If this item is a QWidget, it is returned as a QWidget; otherwise 0 is returned.
QSize sizeHint() const
Reimplemented Function
virtual int heightForWidth(int) const
Returns the preferred height for this layout item, given the width w.
The QSize class defines the size of a two-dimensional object using integer point precision.
bool hasHeightForWidth() const
Reimplemented Function
QRect geometry() const
Reimplemented Function
QLayout * layout()
Reimplemented Function
static const int QLAYOUTSIZE_MAX
int stretch(int index) const
Returns the stretch factor at position index.
void insertSpacerItem(int index, QSpacerItem *spacerItem)
Inserts spacerItem at position index, with zero minimum size and stretch factor.
static void qMaxExpCalc(int &max, bool &exp, bool &empty, int boxmax, bool boxexp, bool boxempty)
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
void changeSize(int w, int h, QSizePolicy::Policy hData=QSizePolicy::Minimum, QSizePolicy::Policy vData=QSizePolicy::Minimum)
Changes this spacer item to have preferred width w, preferred height h, horizontal size policy hPolic...
int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1, QSizePolicy::ControlTypes controls2, Qt::Orientation orientation, QStyleOption *option=0, QWidget *widget=0) const
Returns the spacing that should be used between controls1 and controls2 in a layout.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.
int heightForWidth(int) const
Reimplemented Function
The QList class is a template class that provides lists.