diff --git a/src/layouts/qgridlayoutengine.cpp b/src/layouts/qgridlayoutengine.cpp index d091d124ea4c2cd4688fb50ac23df7219dcc9a8b..bba1efbd0542b634e0d4134f703132396a58cc13 100644 --- a/src/layouts/qgridlayoutengine.cpp +++ b/src/layouts/qgridlayoutengine.cpp @@ -291,7 +291,7 @@ void QGridLayoutRowData::calculateGeometries(int start, int end, qreal targetSiz int stretch = stretches[start + i]; if (sumStretches == 0) { - if (hasIgnoreFlag) { + if (hasIgnoreFlag || sizes[i] == 0.0) { factors[i] = (stretch < 0) ? 1.0 : 0.0; } else { factors[i] = (stretch < 0) ? sizes[i] : 0.0; diff --git a/tests/auto/controls/data/tst_rowlayout.qml b/tests/auto/controls/data/tst_rowlayout.qml index f462bd78ca71b39db85d75c878b1e6296061b8a2..fd21f47560de6215bcf4b039bbb3d08c40cc6058 100644 --- a/tests/auto/controls/data/tst_rowlayout.qml +++ b/tests/auto/controls/data/tst_rowlayout.qml @@ -556,6 +556,54 @@ Item { } + Component { + id: layout_rowLayout_Component + RowLayout { + } + } + + function test_stretchItem_data() + { + return [ + { expectedWidth: 0}, + { preferredWidth: 20, expectedWidth: 20}, + { preferredWidth: 0, expectedWidth: 0}, + { preferredWidth: 20, fillWidth: true, expectedWidth: 100}, + { width: 20, fillWidth: true, expectedWidth: 100}, + { width: 0, fillWidth: true, expectedWidth: 100}, + { preferredWidth: 0, fillWidth: true, expectedWidth: 100}, + { preferredWidth: 1, maximumWidth: 0, fillWidth: true, expectedWidth: 0}, + { preferredWidth: 0, minimumWidth: 1, expectedWidth: 1}, + ]; + } + + function test_stretchItem(data) + { + var layout = layout_rowLayout_Component.createObject(container) + var r = layoutItem_Component.createObject(layout) + // Reset previously relevant properties + r.width = 0 + r.implicitWidth = 0 + compare(layout.implicitWidth, 0) + + if (data.preferredWidth !== undefined) + r.Layout.preferredWidth = data.preferredWidth + if (data.fillWidth !== undefined) + r.Layout.fillWidth = data.fillWidth + if (data.width !== undefined) + r.width = data.width + if (data.minimumWidth !== undefined) + r.Layout.minimumWidth = data.minimumWidth + if (data.maximumWidth !== undefined) + r.Layout.maximumWidth = data.maximumWidth + + layout.width = 100 + + compare(r.width, data.expectedWidth) + + layout.destroy(); + } + Component { id: layout_alignToPixelGrid_Component RowLayout {