diff options
-rw-r--r-- | src/gui/graphicsview/qgridlayoutengine.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp | 26 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp index f1055ba..a3c7ff5 100644 --- a/src/gui/graphicsview/qgridlayoutengine.cpp +++ b/src/gui/graphicsview/qgridlayoutengine.cpp @@ -194,7 +194,8 @@ void QGridLayoutRowData::distributeMultiCells(const QGridLayoutRowInfo &rowInfo) for (int k = 0; k < span; ++k) { boxes[start + k].combine(extras[k]); - stretches[start + k] = qMax(stretches[start + k], stretch); + if (stretch != 0) + stretches[start + k] = qMax(stretches[start + k], stretch); } } multiCellMap.clear(); @@ -1472,7 +1473,7 @@ void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData, const QLayoutSt QGridLayoutBox *box; if (effectiveRowSpan == 1) { box = &rowBox; - if (!userRowStretch) + if (!userRowStretch && itemStretch != 0) rowStretch = qMax(rowStretch, itemStretch); } else { QGridLayoutMultiCellData &multiCell = diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp index 965e340..48dea0c 100644 --- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp +++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp @@ -106,6 +106,7 @@ private slots: void testAlignmentInLargerLayout(); void testOffByOneInLargerLayout(); void testDefaultAlignment(); + void combineSizePolicies(); // Task specific tests void task218400_insertStretchCrash(); @@ -1583,6 +1584,31 @@ void tst_QGraphicsLinearLayout::testDefaultAlignment() QCOMPARE(w2->geometry(), QRectF(0,50,100,100)); } +void tst_QGraphicsLinearLayout::combineSizePolicies() +{ + QGraphicsWidget *widget = new QGraphicsWidget; + QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal, widget); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + + QGraphicsWidget *w1 = new QGraphicsWidget; + w1->setMaximumSize(200,200); + w1->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + layout->addItem(w1); + + QGraphicsWidget *w2 = new QGraphicsWidget; + w2->setPreferredSize(50,50); + w2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + layout->addItem(w2); + QCOMPARE(layout->maximumHeight(), qreal(200)); + + // now remove the fixed vertical size policy, and set instead the maximum height to 50 + // this should in effect give the same maximumHeight + w2->setMaximumHeight(50); + w2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + QCOMPARE(layout->maximumHeight(), qreal(200)); +} + QTEST_MAIN(tst_QGraphicsLinearLayout) #include "tst_qgraphicslinearlayout.moc" |