summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-12-29 12:45:45 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-01-06 13:39:57 +0000
commit0b736d91b779c9f475ccb6a21339d0aa1cada2e4 (patch)
treec42aea3c0aafbf157240082491f53f3d7990175b /src
parent7984327c40a09cdd79f03a52649484e5f0c5704c (diff)
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 <richard.gustavsen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/kernel/qformlayout.cpp5
1 files changed, 4 insertions, 1 deletions
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<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