diff options
-rw-r--r-- | src/gui/graphicsview/qgridlayoutengine.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index 8e6b149..99adb4a 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -1475,7 +1475,7 @@ void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, const QLayoutSt 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/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index d146b19..69291f5 100644 --- a/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -126,6 +126,7 @@ private slots: void spanningItem2x3_data(); void spanningItem2x3(); void spanningItem(); + void spanAcrossEmptyRow(); void heightForWidth(); void widthForHeight(); void heightForWidthWithSpanning(); @@ -3355,6 +3356,33 @@ void tst_QGraphicsGridLayout::spanningItem() QCOMPARE(layout->maximumSize(), QSizeF(160,80)); } +void tst_QGraphicsGridLayout::spanAcrossEmptyRow() +{ + QGraphicsWidget *form = new QGraphicsWidget(0, Qt::Window); + QGraphicsGridLayout *layout = new QGraphicsGridLayout(form); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + RectWidget *w1 = new RectWidget; + RectWidget *w2 = new RectWidget; + RectWidget *w3 = new RectWidget; + + QSizeF size(10, 10); + for (int i = 0; i < 3; ++i) { + w1->setSizeHint((Qt::SizeHint)i, size); + w2->setSizeHint((Qt::SizeHint)i, size); + w3->setSizeHint((Qt::SizeHint)i, size); + size+=size; //[(10,10), (20,20), (40,40)] + } + layout->addItem(w1, 0, 0, 1, 1); + layout->addItem(w2, 0, 1, 1, 2); + layout->addItem(w3, 0, 99, 1, 1); + + form->resize(60,20); + QCOMPARE(w1->geometry(), QRectF( 0, 0, 20, 20)); + QCOMPARE(w2->geometry(), QRectF(20, 0, 20, 20)); + QCOMPARE(w3->geometry(), QRectF(40, 0, 20, 20)); +} + void tst_QGraphicsGridLayout::stretchAndHeightForWidth() { QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); |