diff options
Diffstat (limited to 'src/widgets/kernel/qformlayout.cpp')
-rw-r--r-- | src/widgets/kernel/qformlayout.cpp | 67 |
1 files changed, 18 insertions, 49 deletions
diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 595ff3eb6e..9146ba84c8 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -419,13 +419,15 @@ void QFormLayoutPrivate::updateSizes() if (label) { maxMinLblWidth = qMax(maxMinLblWidth, label->minSize.width()); maxShLblWidth = qMax(maxShLblWidth, label->sizeHint.width()); - if (field) { + } + if (field) { + if (field->fullRow) { + maxMinIfldWidth = qMax(maxMinIfldWidth, field->minSize.width()); + maxShIfldWidth = qMax(maxShIfldWidth, field->sizeHint.width()); + } else { maxMinFldWidth = qMax(maxMinFldWidth, field->minSize.width() + field->sbsHSpace); maxShFldWidth = qMax(maxShFldWidth, field->sizeHint.width() + field->sbsHSpace); } - } else if (field) { - maxMinIfldWidth = qMax(maxMinIfldWidth, field->minSize.width()); - maxShIfldWidth = qMax(maxShIfldWidth, field->sizeHint.width()); } prevLbl = label; @@ -781,7 +783,7 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) vLayouts[vidx].expansive = expanding || (vLayouts[vidx].stretch > 0); vLayouts[vidx].empty = false; - if (vLayouts[vidx].stretch > 0) + if (vLayouts[vidx].expansive) addTopBottomStretch = false; if (vidx > 1) @@ -1435,13 +1437,7 @@ static void clearAndDestroyQLayoutItem(QLayoutItem *item) up one row and the freed vertical space is redistributed amongst the remaining rows. You can use this function to undo a previous addRow() or insertRow(): - \code - QFormLayout *flay = ...; - QPointer<QLineEdit> le = new QLineEdit; - flay->insertRow(2, "User:", le); - // later: - flay->removeRow(2); // le == nullptr at this point - \endcode + \snippet code/src_gui_kernel_qformlayout.cpp 3 If you want to remove the row from the layout without deleting the widgets, use takeRow() instead. @@ -1467,13 +1463,7 @@ void QFormLayout::removeRow(int row) up one row and the freed vertical space is redistributed amongst the remaining rows. You can use this function to undo a previous addRow() or insertRow(): - \code - QFormLayout *flay = ...; - QPointer<QLineEdit> le = new QLineEdit; - flay->insertRow(2, "User:", le); - // later: - flay->removeRow(le); // le == nullptr at this point - \endcode + \snippet code/src_gui_kernel_qformlayout.cpp 4 If you want to remove the row from the layout without deleting the widgets, use takeRow() instead. @@ -1499,13 +1489,7 @@ void QFormLayout::removeRow(QWidget *widget) up one row and the freed vertical space is redistributed amongst the remaining rows. You can use this function to undo a previous addRow() or insertRow(): - \code - QFormLayout *flay = ...; - QPointer<QVBoxLayout> vbl = new QVBoxLayout; - flay->insertRow(2, "User:", vbl); - // later: - flay->removeRow(layout); // vbl == nullptr at this point - \endcode + \snippet code/src_gui_kernel_qformlayout.cpp 5 If you want to remove the row from the form layout without deleting the inserted layout, use takeRow() instead. @@ -1532,13 +1516,7 @@ void QFormLayout::removeRow(QLayout *layout) up one row and the freed vertical space is redistributed amongst the remaining rows. You can use this function to undo a previous addRow() or insertRow(): - \code - QFormLayout *flay = ...; - QPointer<QLineEdit> le = new QLineEdit; - flay->insertRow(2, "User:", le); - // later: - QFormLayout::TakeRowResult result = flay->takeRow(2); - \endcode + \snippet code/src_gui_kernel_qformlayout.cpp 6 If you want to remove the row from the layout and delete the widgets, use removeRow() instead. @@ -1583,13 +1561,7 @@ QFormLayout::TakeRowResult QFormLayout::takeRow(int row) After this call, rowCount() is decremented by one. All following rows are shifted up one row and the freed vertical space is redistributed amongst the remaining rows. - \code - QFormLayout *flay = ...; - QPointer<QLineEdit> le = new QLineEdit; - flay->insertRow(2, "User:", le); - // later: - QFormLayout::TakeRowResult result = flay->takeRow(widget); - \endcode + \snippet code/src_gui_kernel_qformlayout.cpp 7 If you want to remove the row from the layout and delete the widgets, use removeRow() instead. @@ -1628,13 +1600,7 @@ QFormLayout::TakeRowResult QFormLayout::takeRow(QWidget *widget) After this call, rowCount() is decremented by one. All following rows are shifted up one row and the freed vertical space is redistributed amongst the remaining rows. - \code - QFormLayout *flay = ...; - QPointer<QVBoxLayout> vbl = new QVBoxLayout; - flay->insertRow(2, "User:", vbl); - // later: - QFormLayout::TakeRowResult result = flay->takeRow(widget); - \endcode + \snippet code/src_gui_kernel_qformlayout.cpp 8 If you want to remove the row from the form layout and delete the inserted layout, use removeRow() instead. @@ -1861,7 +1827,7 @@ int QFormLayout::rowCount() const /*! Returns the layout item in the given \a row with the specified \a - role (column). Returns 0 if there is no such item. + role (column). Returns \nullptr if there is no such item. \sa QLayout::itemAt(), setItem() */ @@ -2243,8 +2209,11 @@ void QFormLayoutPrivate::arrangeWidgets(const QVector<QLayoutStruct>& layouts, Q QSize sz(qMin(label->layoutWidth, label->sizeHint.width()), height); int x = leftOffset + rect.x() + label->layoutPos; - if (fixedAlignment(q->labelAlignment(), layoutDirection) & Qt::AlignRight) + const auto fAlign = fixedAlignment(q->labelAlignment(), layoutDirection); + if (fAlign & Qt::AlignRight) x += label->layoutWidth - sz.width(); + else if (fAlign & Qt::AlignHCenter) + x += label->layoutWidth / 2 - sz.width() / 2; QPoint p(x, layouts.at(label->vLayoutIndex).pos); // ### expansion & sizepolicy stuff |