Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.9.2, 5.10.1, 5.12.0
-
cc77a0bc549ce8f0b218661e7ae0e82e5b89e0da (qt/qtdeclarative/dev) a5d2fd816bcbee6026894927ae5d049536bfc7ea (qt/qtdeclarative/5.15)
-
Shovelling Snow, Q1/2020 Finale, Q2/2020 kick off
Description
The example uses two Repeaters to set the columns of a GridLayout. The first repeater does the first column and the second does the second column. Inside the repeater the cell is set explicitly with Layout.row and Layout.column.
The code below can also be found in this gist/git repo. https://gist.github.com/Siecje/27f41128863bf8bcbe3ab2a054c67dd7
The output is as follows
QGridLayoutEngine::addItem: Cell (0, 0) already taken QGridLayoutEngine::addItem: Cell (0, 0) already taken QGridLayoutEngine::addItem: Cell (0, 1) already taken QGridLayoutEngine::addItem: Cell (0, 1) already taken
Run this file with qmlscene and then click the button to see the error in the terminal.
import QtQuick 2.7 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.3 as Layouts Item { id: base property var categories: ['one', 'two', 'three'] property var values: [1, 2, 3] width: 800 height: 600 Column { Button { text: "Cause error output" onClicked: { base.categories = ['eleven', 'twelve'] base.values = [11, 12] } } Button { text: "DOES NOT Cause error output" onClicked: { base.categories = ['eleven'] base.values = [11] } } } Layouts.GridLayout { anchors.fill: parent columns: 2 // CATEGORY LABELS... Repeater { model: base.categories // modelData will be the categories Item { Layouts.Layout.row: index Layouts.Layout.column: 0 Layouts.Layout.preferredWidth: _categoryLabel.width Layouts.Layout.fillHeight: true // The actual category label... Text { id: _categoryLabel height: parent.height anchors.right: parent.right text: modelData verticalAlignment: Text.AlignVCenter font.pointSize: 27 leftPadding: 10 } } } Repeater { model: base.values // modelData will be the values Item { Layouts.Layout.row: index Layouts.Layout.column: 1 Layouts.Layout.preferredWidth: _categoryLabel.width Layouts.Layout.fillHeight: true // The actual value label... Text { id: _categoryLabel height: parent.height anchors.right: parent.right text: modelData verticalAlignment: Text.AlignVCenter font.pointSize: 27 leftPadding: 10 } } } } }
Attachments
For Gerrit Dashboard: QTBUG-65121 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
230719,5 | WIP: Delay layouting to updatePolish() to avoid unnecessary work | 5.11 | qt/qtdeclarative | Status: DEFERRED | -2 | 0 |
273647,3 | GridLayout: polish instead of immediately laying out items | 5.13 | qt/qtdeclarative | Status: DEFERRED | -2 | 0 |
297828,7 | Improve performance when dynamically adding items to a layout | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
300927,6 | Improve performance when dynamically adding items to a layout | 5.15 | qt/qtdeclarative | Status: MERGED | +2 | 0 |