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-05 17:58:43 +0000
commit2f9410989243492e715afc5e39c53f78b7214d73 (patch)
tree16141529b93be232d61dc5b20e8ada16653d6cf8
parent78d2487a095d1a01ff2ca1e3bf2190ee19545ee2 (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 6d8993a923..2e08b468a4 100644
--- a/src/quickcontrols2/imagine/GroupBox.qml
+++ b/src/quickcontrols2/imagine/GroupBox.qml
@@ -51,10 +51,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