From 0b736d91b779c9f475ccb6a21339d0aa1cada2e4 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 29 Dec 2018 12:45:45 +0100 Subject: QFormLayout: honor Qt::AlignHCenter for labelAlignment The QFormLayout did not handle Qt::AlignCenter, only Qt::AlignLeft/Right for the labelAlignment property. Therefore also add the code for Qt::AlignHCenter to be consistent Fixes: QTBUG-2780 Change-Id: I0d6dd61ba583e3ee37a003fae000d992505c08d1 Reviewed-by: Richard Moe Gustavsen --- src/widgets/kernel/qformlayout.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 101ce8b64c..7cdddf3133 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -2209,8 +2209,11 @@ void QFormLayoutPrivate::arrangeWidgets(const QVector& 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 -- cgit v1.2.3