Made sure items with preferred width of 0 could also stretch
If no stretch factors were specified, we used the preferred size as a stretch factor. Obviously, that didn't work if the preferred size was actually 0. This patch works around this by actually setting the stretch factor to 1.0 if this is the case. This should work fine in most cases, except for the case where there are also other items with a preferred size close to 0. In this case, the item with preferred size 0 will just grow faster than an item with e.g. preferred size 0.1. Task-number: QTBUG-31217 Change-Id: I966455da0bdd00308591c7f7cfbc4e134d423e57 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>bb10
parent
c9e1c947d4
commit
cf366e8b86
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1884,6 +1884,18 @@ void tst_QGraphicsGridLayout::defaultStretchFactors_data()
|
|||
<< QSizeF(10,10) << QSizeF(10,10) << QSizeF(10,10)
|
||||
);
|
||||
|
||||
QTest::newRow("preferredsizeIsZero") << (ItemList()
|
||||
<< ItemDesc(0,0)
|
||||
.preferredSizeHint(QSizeF(0,10))
|
||||
<< ItemDesc(0,1)
|
||||
.preferredSizeHint(QSizeF(10,10))
|
||||
.maxSize(QSizeF(20, 10))
|
||||
)
|
||||
<< QSizeF(30, 10)
|
||||
<< (SizeList()
|
||||
<< QSizeF(10,10) << QSizeF(20,10)
|
||||
);
|
||||
|
||||
QTest::newRow("ignoreitem01") << (ItemList()
|
||||
<< ItemDesc(0,0)
|
||||
.preferredSizeHint(QSizeF(10,10))
|
||||
|
|
|
|||
Loading…
Reference in New Issue