diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2020-01-16 16:25:06 +0100 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2020-01-16 16:25:06 +0100 |
commit | 1d333d3375874efb8d37df37dc5ef561573794ad (patch) | |
tree | 2d8c995f64c05c84c1fcceb2c5cb40fcae69855f /src/imports/layouts/qquicklinearlayout.cpp | |
parent | b106d86c433706928b0b0c206a0d9f831681e1bf (diff) | |
parent | e79a2658cde899d6ee11ec3c0d0a3768eb2c864b (diff) |
Merge remote-tracking branch 'origin/dev' into wip/cmake
Change-Id: I0c5b939c70bdb91ccdf7068784308416dcaa5736
Diffstat (limited to 'src/imports/layouts/qquicklinearlayout.cpp')
-rw-r--r-- | src/imports/layouts/qquicklinearlayout.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/imports/layouts/qquicklinearlayout.cpp b/src/imports/layouts/qquicklinearlayout.cpp index c6c9685ae2..344ea7237c 100644 --- a/src/imports/layouts/qquicklinearlayout.cpp +++ b/src/imports/layouts/qquicklinearlayout.cpp @@ -645,6 +645,7 @@ void QQuickGridLayout::insertLayoutItems() int &nextColumn = nextCellPos[0]; int &nextRow = nextCellPos[1]; + const QSize gridSize(columns(), rows()); const int flowOrientation = flow(); int &flowColumn = nextCellPos[flowOrientation]; int &flowRow = nextCellPos[1 - flowOrientation]; @@ -664,7 +665,7 @@ void QQuickGridLayout::insertLayoutItems() if (shouldIgnoreItem(child, info, sizeHints)) continue; - Qt::Alignment alignment = nullptr; + Qt::Alignment alignment; int row = -1; int column = -1; int span[2] = {1,1}; @@ -677,8 +678,21 @@ void QQuickGridLayout::insertLayoutItems() // the unspecified component of the cell position should default to 0 // The getters do this for us, as they will return 0 for an // unset (or negative) value. - row = info->row(); - column = info->column(); + // In addition, if \a rows is less than Layout.row, treat Layout.row as if it was not set + // This will basically make it find the next available cell (potentially wrapping to + // the next line). Likewise for an invalid Layout.column + + if (gridSize.height() >= 0 && row >= gridSize.height()) { + qmlWarning(child) << QString::fromLatin1("Layout: row (%1) should be less than the number of rows (%2)").arg(info->row()).arg(rows()); + } else { + row = info->row(); + } + + if (gridSize.width() >= 0 && info->column() >= gridSize.width()) { + qmlWarning(child) << QString::fromLatin1("Layout: column (%1) should be less than the number of columns (%2)").arg(info->column()).arg(columns()); + } else { + column = info->column(); + } } rowSpan = info->rowSpan(); columnSpan = info->columnSpan(); @@ -840,7 +854,7 @@ void QQuickLinearLayout::insertLayoutItems() if (shouldIgnoreItem(child, info, sizeHints)) continue; - Qt::Alignment alignment = nullptr; + Qt::Alignment alignment; if (info) alignment = info->alignment(); |