aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Eftevaag <oliver.eftevaag@qt.io>2022-02-02 13:42:01 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-08 14:18:34 +0000
commit1061b2de732ca2efcbb84305fb3825f13398c7b3 (patch)
treea21dea4ffa2fe4d93c9baa1cd88e45c0921d102c
parent07e0a8069974af0783dedcb2dcff0df6fd82c037 (diff)
Imagine GroupBox: Ignore background topPadding unless it's a 9PatchImage
The background property inherited from QQuickControl is a QQuickItem, which doesn't have properties for padding. The Imagine style GroupBox implementation would use duck typing to access potential padding properties for the background item, and if the background item does not have the padding properties being queried, the expression will resolve to have the 'undefined' javascript value. Since 'undefined' is NaN boxed internally to be a nullptr, the setter for the leftPadding, rightPadding and bottomPadding would essentially be called with the value '0' as the argument. But the topPadding property had a more complex binding, using the + operator in its expression. The javascript expression 'undefined' + 'some number' will evaluate to the value 'NaN', which is what the setter for the topPadding property would end up receiving as the argument value. This patch changes the binding expressions for the padding properties to only add the background item's padding, if the background is a NinePatchImage, which is the default type used by the Imagine style. Fixes: QTBUG-94161 Change-Id: I8de6f47350fa8b6253948fb1be63d651a15d1d58 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit ab46156ee6a8fbe6e50353d2f0c73fdc964bae75) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/quickcontrols2/imagine/GroupBox.qml8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/quickcontrols2/imagine/GroupBox.qml b/src/quickcontrols2/imagine/GroupBox.qml
index b0a8645f72..3fc99d97e1 100644
--- a/src/quickcontrols2/imagine/GroupBox.qml
+++ b/src/quickcontrols2/imagine/GroupBox.qml
@@ -48,10 +48,10 @@ T.GroupBox {
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
contentHeight + topPadding + bottomPadding)
- topPadding: (background ? background.topPadding : 0) + (implicitLabelWidth > 0 ? implicitLabelHeight + spacing : 0)
- leftPadding: background ? background.leftPadding : 0
- rightPadding: background ? background.rightPadding : 0
- bottomPadding: background ? background.bottomPadding : 0
+ topPadding: ((background as NinePatchImage)?.topPadding ?? 0) + (implicitLabelWidth > 0 ? implicitLabelHeight + spacing : 0)
+ leftPadding: ((background as NinePatchImage)?.leftPadding ?? 0)
+ rightPadding: ((background as NinePatchImage)?.rightPadding ?? 0)
+ bottomPadding: ((background as NinePatchImage)?.bottomPadding ?? 0)
label: Label {
width: control.width