Skip to content

Commit

Permalink
Fixed a bug where spans did not always work in layouts.
Browse files Browse the repository at this point in the history
The problem was that the span we stored in the multiCellMap was the
"effective" span (i.e.  the given span subtracted with the number of
ignored rows it would span). Later we used that span to distribute its
size across all its cells.  However, since the span now could be smaller
that the given span, we could sometimes fail to distribute to the last
span(s).

[ChangeLog][QtWidgets][layouts] Fixed a bug where spans sometimes didn't
distribute themselves to the last cells they covered.

Change-Id: I31db3d850484dc8b70d62c5f02f680740578c661
Task-number: QTBUG-43099
Reviewed-by: Paul Olav Tvete <[email protected]>
  • Loading branch information
Jan Arve Saether committed Dec 9, 2014
1 parent 68d5286 commit c9db6e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gui/util/qgridlayoutengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ void QGridLayoutEngine::fillRowData(QGridLayoutRowData *rowData,
rowStretch = qMax(rowStretch, itemStretch);
} else {
QGridLayoutMultiCellData &multiCell =
rowData->multiCellMap[qMakePair(row, effectiveRowSpan)];
rowData->multiCellMap[qMakePair(row, itemRowSpan)];
box = &multiCell.q_box;
multiCell.q_stretch = itemStretch;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,23 @@ void tst_QGraphicsGridLayout::sizeHint_data()
<< QSizeF(100, 100)
<< QSizeF(100, 100);

QTest::newRow("colSpan_with_ignored_column") << (ItemList()
<< ItemDesc(0,0)
.minSize(QSizeF(40,20))
.maxSize(QSizeF(60,20))
.colSpan(2)
<< ItemDesc(0,2)
.minSize(QSizeF(20, 20))
.maxSize(QSizeF(30, 20))
<< ItemDesc(1,0)
.minSize(QSizeF(60, 20))
.maxSize(QSizeF(90, 20))
.colSpan(3)
)
<< QSizeF(60, 40)
<< QSizeF(80, 40)
<< QSizeF(90, 40);

}

// public QSizeF sizeHint(Qt::SizeHint which, QSizeF const& constraint = QSizeF()) const
Expand Down

0 comments on commit c9db6e5

Please sign in to comment.