19template <
class T,
int NumColumns>
28 const T &
operator()(
int r,
int c)
const {
return m_storage[
r * NumColumns +
c]; }
44template <
class T,
int NumColumns>
52template <
class T,
int NumColumns>
58template <
class T,
int NumColumns>
61 *rowPtr = idx / NumColumns;
62 *colPtr = idx % NumColumns;
127 else if (
item->layout())
225 expandVertical(0), expandHorizontal(0)
245 return m.storage().indexOf(
item);
255 item->minSize =
item->item->minimumSize();
256 item->sizeHint =
item->item->sizeHint();
257 item->maxSize =
item->item->maximumSize();
262 item->maxSize.setWidth(
item->sizeHint.width());
264 item->isHfw =
item->item->hasHeightForWidth();
265 item->vSpace = userVSpacing;
288 bool expandH =
false;
289 bool expandV =
false;
297 int userVSpacing =
q->verticalSpacing();
298 int userHSpacing = wrapAllRows ? 0 :
q->horizontalSpacing();
300 int maxMinLblWidth = 0;
301 int maxMinFldWidth = 0;
302 int maxMinIfldWidth = 0;
304 int maxShLblWidth = 0;
305 int maxShFldWidth = 0;
306 int maxShIfldWidth = 0;
308 for (
int i = 0;
i < rr; ++
i) {
313 if (!
label && !field)
320 Qt::Orientations
o =
label->expandingDirections();
342 if ((userHSpacing < 0 || userVSpacing < 0) && style) {
343 QSizePolicy::ControlTypes lbltypes =
345 QSizePolicy::ControlTypes fldtypes =
349 if (userVSpacing < 0) {
355 QSizePolicy::ControlTypes lbltoptypes =
357 QSizePolicy::ControlTypes fldtoptypes =
368 QSizePolicy::ControlTypes lbltoptypes =
370 QSizePolicy::ControlTypes fldtoptypes =
378 label->vSpace =
qMax(lblspacing, fldspacing);
400 if (userHSpacing < 0 && !wrapAllRows && (
label || !field->
fullRow) && field)
412 maxMinLblWidth =
qMax(maxMinLblWidth,
label->minSize.width());
413 maxShLblWidth =
qMax(maxShLblWidth,
label->sizeHint.width());
435 }
else if (dontWrapRows) {
437 sh_width =
qMax(maxShLblWidth + maxShFldWidth, maxShIfldWidth);
438 min_width =
qMax(maxMinLblWidth + maxMinFldWidth, maxMinIfldWidth);
442 sh_width =
qMax(maxShLblWidth + maxShFldWidth, maxShIfldWidth);
502 for (
i = 0;
i < rr; ++
i) {
507 if (!
q->isRowVisible(
i))
514 int hfw =
label->heightForWidth(
label->layoutWidth);
592 if (style && prevItem1) {
593 QSizePolicy::ControlTypes itemtypes =
646 bool addTopBottomStretch =
true;
653 int userVSpacing =
q->verticalSpacing();
655 if (userVSpacing < 0) {
669 for (
int i = 0;
i < rr; ++
i) {
681 bool prevRowSplit =
false;
683 for (
int i = 0;
i < rr; ++
i) {
689 if (!
q->isRowVisible(
i)) {
691 label->vLayoutIndex = -1;
702 min1 =
label->minSize;
703 sh1 =
label->sizeHint;
715 if (wrapAllRows || splitSideBySide) {
720 vLayouts[vidx - 1].spacing =
spacingHelper(
q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit,
label,
nullptr, prevItem1, prevItem2);
722 label->vLayoutIndex = vidx;
723 label->sideBySide =
false;
729 addTopBottomStretch =
false;
738 vLayouts[vidx - 1].spacing =
spacingHelper(
q->parentWidget(), style, userVSpacing, splitSideBySide || prevRowSplit, field,
nullptr, prevItem1, prevItem2);
747 addTopBottomStretch =
false;
752 prevRowSplit = splitSideBySide;
760 bool expanding =
false;
763 max1 =
label->maxSize;
767 label->sideBySide = (field !=
nullptr);
768 label->vLayoutIndex = vidx;
769 stretch1 =
label->vStretch();
789 addTopBottomStretch =
false;
792 vLayouts[vidx - 1].spacing =
spacingHelper(
q->parentWidget(), style, userVSpacing, prevRowSplit,
label, field, prevItem1, prevItem2);
802 prevRowSplit =
false;
807 if (addTopBottomStretch) {
838 int fieldMaxWidth = 0;
843 for (
int i = 0;
i < rr; ++
i) {
848 if (!
label && !field)
855 label->layoutPos = 0;
890 int leftMargin, topMargin, rightMargin, bottomMargin;
891 q->getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin);
897 int h = topMargin + bottomMargin;
898 int mh = topMargin + bottomMargin;
901 int w =
sh_width + leftMargin + rightMargin;
902 int mw =
min_width + leftMargin + rightMargin;
953 qWarning(
"QFormLayoutPrivate::setItem: Cell (%d, %d) already occupied",
row,
column);
958 i->fullRow = fullRow;
991 return parentWidget->style();
1004 qWarning(
"QFormLayoutPrivate::replaceAt: Invalid index %d",
index);
1016 item->item = newitem;
1221 d->m_things.clear();
1223 d->m_matrix.clear();
1300 if ((
label && !
d->checkWidget(
label)) || (field && !
d->checkWidget(field)))
1317 if ((
label && !
d->checkWidget(
label)) || (field && !
d->checkLayout(field)))
1338 if (field && !
d->checkWidget(field))
1344#ifndef QT_NO_SHORTCUT
1345 label->setBuddy(field);
1360 if (field && !
d->checkLayout(field))
1409 item->item =
nullptr;
1414 if (l->parent() ==
layout)
1415 l->setParent(
nullptr);
1424 delete item->widget();
1539 qWarning(
"QFormLayout::takeRow: Invalid row %d",
row);
1546 d->m_things.removeOne(
label);
1547 d->m_things.removeOne(field);
1548 d->m_matrix.removeRow(
row);
1590 qWarning(
"QFormLayout::takeRow: Invalid widget");
1630 qWarning(
"QFormLayout::takeRow: Invalid layout");
1644 int row =
d->insertRow(
d->m_matrix.rowCount());
1655 return d->m_things.size();
1665 return formItem->item;
1688 d->m_things.removeAt(
index);
1689 d->m_matrix(
row, col) = 0;
1706 if (
e->expandHorizontal)
1708 if (
e->expandVertical)
1733 int leftMargin, topMargin, rightMargin, bottomMargin;
1736 int targetWidth =
width - leftMargin - rightMargin;
1738 if (!
d->haveHfwCached(targetWidth)) {
1744 if (targetWidth ==
d->sh_width)
1745 return d->hfw_sh_height + topMargin + bottomMargin;
1747 return d->hfw_height + topMargin + bottomMargin;
1758 int leftMargin, topMargin, rightMargin, bottomMargin;
1760 cr.
adjust(+leftMargin, +topMargin, -rightMargin, -bottomMargin);
1763 d->setupVerticalLayoutData(cr.
width());
1764 d->setupHorizontalLayoutData(cr.
width());
1765 if (hfw && (!
d->haveHfwCached(cr.
width()) ||
d->hfwLayouts.size() !=
d->vLayoutCount))
1766 d->recalcHFW(cr.
width());
1769 d->arrangeWidgets(
d->hfwLayouts, cr);
1772 d->arrangeWidgets(
d->vLayouts, cr);
1784 if (!
d->prefSize.isValid()) {
1798 if (!
d->minSize.isValid()) {
1812 d->sizesDirty =
true;
1815 d->formMaxWidth = -1;
1818 d->layoutWidth = -1;
1819 d->hfw_sh_height = -1;
1831 return d->m_matrix.rowCount();
1875 if (storageIndex != -1)
1880 if (rolePtr &&
row != -1) {
1881 const bool spanning = col == 1 &&
d->m_matrix(
row, col)->fullRow;
1939 return label->widget();
1958 return label->widget();
1984 d->fieldGrowthPolicy =
policy;
2056 if (!
d->labelAlignment) {
2059 return d->labelAlignment;
2086 if (!
d->formAlignment) {
2089 return d->formAlignment;
2115 if (
d->hSpacing >= 0) {
2144 if (
d->vSpacing >= 0) {
2198 for (
i = 0;
i < rr; ++
i) {
2202 if (!
q->isRowVisible(
i))
2216 label->maxSize.height()));
2221 const auto fAlign =
fixedAlignment(
q->labelAlignment(), layoutDirection);
2265 d->insertRows(rowCnt,
row - rowCnt + 1);
2285 d->insertRows(rowCnt,
row - rowCnt + 1);
2307 d->insertRows(rowCnt,
row - rowCnt + 1);
2325 bool change =
false;
2327 change =
label->isVisible != on;
2328 label->setVisible(on);
2359 qWarning(
"QFormLayout::setRowVisible: Invalid widget");
2387 qWarning(
"QFormLayout::setRowVisible: Invalid layout");
2406 int visibleItemCount = 2;
2412 return visibleItemCount > 0;
2432 qWarning(
"QFormLayout::takeRow: Invalid widget");
2456 qWarning(
"QFormLayout::takeRow: Invalid layout");
2467void QFormLayout::resetFieldGrowthPolicy()
2477void QFormLayout::resetRowWrapPolicy()
2487void QFormLayout::resetFormAlignment()
2490 d->formAlignment = { };
2497void QFormLayout::resetLabelAlignment()
2500 d->labelAlignment = { };
2504void QFormLayout::dump()
const
2508 for (
int j = 0;
j < 2; ++
j) {
2509 qDebug(
"m_matrix(%d, %d) = %p",
i,
j,
d->m_matrix(
i,
j));
2512 for (
int i = 0;
i <
d->m_things.count(); ++
i)
2513 qDebug(
"m_things[%d] = %p",
i,
d->m_things.at(
i));
2519#include "moc_qformlayout.cpp"
static QStyle * style()
Returns the application's style object.
int count() const override
\reimp
QLayoutItem * takeAt(int) override
\reimp
QLayoutItem * itemAt(int) const override
\reimp
Qt::LayoutDirection layoutDirection
the default layout direction for this application
The QLabel widget provides a text or image display.
The QLayoutItem class provides an abstract item that a QLayout manipulates.
virtual Qt::Orientations expandingDirections() const =0
Returns whether this layout item can make use of more space than sizeHint().
virtual QRect geometry() const =0
Returns the rectangle covered by this layout item.
virtual QSizePolicy::ControlTypes controlTypes() const
Returns the control type(s) for the layout item.
virtual bool hasHeightForWidth() const
Returns true if this layout's preferred height depends on its width; otherwise returns false.
virtual int heightForWidth(int) const
Returns the preferred height for this layout item, given the width, which is not used in this default...
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise \nullptr is returned.
Qt::Alignment alignment() const
Returns the alignment of this item.
virtual void setGeometry(const QRect &)=0
Implemented in subclasses to set this item's geometry to r.
virtual int minimumHeightForWidth(int) const
Returns the minimum height this widget needs for the given width, w.
virtual QWidget * widget() const
If this item manages a QWidget, returns that widget.
virtual void invalidate()
Invalidates any cached information in this layout item.
static QWidgetItem * createWidgetItem(const QLayout *layout, QWidget *widget)
The QLayout class is the base class of geometry managers.
QRect geometry() const override
\reimp
void getContentsMargins(int *left, int *top, int *right, int *bottom) const
void invalidate() override
\reimp
virtual void setGeometry(const QRect &) override
\reimp
QLayout * layout() override
\reimp
virtual int indexOf(const QWidget *) const
Searches for widget widget in this layout (not including child layouts).
qsizetype size() const noexcept
bool empty() const noexcept
const_reference at(qsizetype i) const noexcept
T value(qsizetype i) const
void resize(qsizetype size)
void append(parameter_type t)
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr int verticalStretch() const noexcept
Returns the vertical stretch factor of the size policy.
constexpr QSize boundedTo(const QSize &) const noexcept
Returns a size holding the minimum width and height of this size and the given otherSize.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr int & rheight() noexcept
Returns a reference to the height.
constexpr int & rwidth() noexcept
Returns a reference to the width.
constexpr bool isValid() const noexcept
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
@ SH_FormLayoutWrapPolicy
@ SH_FormLayoutFieldGrowthPolicy
@ SH_FormLayoutFormAlignment
@ SH_FormLayoutLabelAlignment
static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
Returns the given logicalRectangle converted to screen coordinates based on the specified direction.
int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1, QSizePolicy::ControlTypes controls2, Qt::Orientation orientation, QStyleOption *option=nullptr, QWidget *widget=nullptr) const
@ PM_LayoutVerticalSpacing
@ PM_LayoutHorizontalSpacing
const T & operator()(int r, int c) const
static void storageIndexToPosition(int idx, int *rowPtr, int *colPtr)
const Storage & storage() const
T & operator()(int r, int c)
void insertRow(int r, const T &value)
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static QGtk3Storage * m_storage
Q_WIDGETS_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm)
void qGeomCalc(QList< QLayoutStruct > &chain, int start, int count, int pos, int space, int spacer)
QT_BEGIN_NAMESPACE constexpr int QLAYOUTSIZE_MAX
static const double leftOffset
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLenum GLsizei count
GLuint GLsizei const GLchar * label
[43]
GLfloat GLfloat GLfloat GLfloat h
GLenum GLenum GLsizei void GLsizei void * column
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLsizei void * row
void init(int stretchFactor=0, int minSize=0)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent