diff --git a/src/layouts/qgridlayoutengine.cpp b/src/layouts/qgridlayoutengine.cpp index c5a1b5ce6d2e4743008617e23329df62391fca85..f72bffe26e32543d08635334021bc984e2532d3e 100644 --- a/src/layouts/qgridlayoutengine.cpp +++ b/src/layouts/qgridlayoutengine.cpp @@ -1419,7 +1419,7 @@ void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, int effectiveRowSpan = 1; for (int i = 1; i < itemRowSpan; ++i) { - if (!rowData->ignore.testBit(i)) + if (!rowData->ignore.testBit(i + itemRow)) ++effectiveRowSpan; } diff --git a/tests/auto/controls/data/tst_gridlayout.qml b/tests/auto/controls/data/tst_gridlayout.qml index da1cd81495ac6bc2928570b205d8af9ffc4fedff..2315dc14e697fffcac319b850788cbb661311849 100644 --- a/tests/auto/controls/data/tst_gridlayout.qml +++ b/tests/auto/controls/data/tst_gridlayout.qml @@ -322,5 +322,57 @@ Item { layout.destroy(); } + + Component { + id: layout_spans_Component + GridLayout { + columnSpacing: 0 + rowSpacing: 0 + // black rectangles are explicitly positioned with row,column + Rectangle { + // (0,0) + id: r0 + color: "black" + width: 20 + height: 20 + Layout.row: 0 + Layout.column: 0 + } + Rectangle { + // (0,1) + id: r1 + color: "black" + width: 20 + height: 20 + Layout.row: 0 + Layout.column: 1 + Layout.columnSpan: 2 + Layout.rowSpan: 2 + } + Rectangle { + // (99,99) + id: r2 + color: "black" + width: 20 + height: 20 + Layout.row: 99 + Layout.column: 99 + } + } + } + + function test_spans() { + var layout = layout_spans_Component.createObject(container); + compare(layout.children[0].x, 0); + compare(layout.children[0].y, 0); + compare(layout.children[1].x, 20); + compare(layout.children[1].y, 0); + compare(layout.children[2].x, 40); + compare(layout.children[2].y, 20); + + layout.destroy(); + } + + } }