Commit 4435aaef authored by Jan Arve Saether's avatar Jan Arve Saether Committed by The Qt Project
Browse files

Repopulate the GridLayout if flow is changed


This is needed because changing the flow will change which
cell an item is associated with.

Change-Id: Id84d1710fb6d7debe72a859c52b505e1e47f06b0
Reviewed-by: default avatarRichard Moe Gustavsen <richard.gustavsen@digia.com>
parent 25e937a7
Branches
Tags
No related merge requests found
Showing with 42 additions and 1 deletion
......@@ -515,7 +515,8 @@ void QQuickGridLayout::setFlow(QQuickGridLayout::Flow flow)
if (d->flow == flow)
return;
d->flow = flow;
invalidate();
// If flow is changed, the layout needs to be repopulated
updateLayoutItems();
emit flowChanged();
}
......
......@@ -58,6 +58,46 @@ Item {
return [item.x, item.y, item.width, item.height];
}
Component {
id: layout_flow_Component
GridLayout {
columns: 4
columnSpacing: 0
rowSpacing: 0
Repeater {
model: 6
Rectangle {
color: "red"
Layout.preferredWidth: 10
Layout.preferredHeight: 10
Text { text: index }
}
}
}
}
function test_flow()
{
var layout = layout_flow_Component.createObject(container);
compare(itemRect(layout.children[0]), [ 0, 0, 10, 10])
compare(itemRect(layout.children[1]), [10, 0, 10, 10])
compare(itemRect(layout.children[2]), [20, 0, 10, 10])
compare(itemRect(layout.children[3]), [30, 0, 10, 10])
compare(itemRect(layout.children[4]), [ 0, 10, 10, 10])
compare(itemRect(layout.children[5]), [10, 10, 10, 10])
layout.rows = 4
layout.flow = GridLayout.TopToBottom
compare(itemRect(layout.children[0]), [ 0, 0, 10, 10])
compare(itemRect(layout.children[1]), [ 0, 10, 10, 10])
compare(itemRect(layout.children[2]), [ 0, 20, 10, 10])
compare(itemRect(layout.children[3]), [ 0, 30, 10, 10])
compare(itemRect(layout.children[4]), [10, 0, 10, 10])
compare(itemRect(layout.children[5]), [10, 10, 10, 10])
}
Component {
id: layout_flowLeftToRight_Component
GridLayout {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment