Skip to content

forms(qml): DynamicForm.gridColumns -- a host lays the fields out on a grid of its own - #823

Merged
Yaraslaut merged 1 commit into
masterfrom
feature/forms-grid-columns
Sep 25, 2026
Merged

Yaraslaut merged 1 commit into
masterfrom
feature/forms-grid-columns

Conversation

@Yaraslaut

Copy link
Copy Markdown
Member

What / why

All of DynamicForm's field grids had fixed column counts:

  • sections and tab sets used 2 columns
  • the implicit flat bucket used 1
  • the grid created inside a host's section/tab-set chrome was passed a literal 2

A host whose UI kit lays forms out on a 12-column grid could declare x-colspan, but the renderer never built a grid with that many columns to count the span against.

Contract

Property Default Applies to
gridColumns 2 Every section grid, every tab-set grid, and the grid createFieldGrid() creates inside a section/accordion/tab-set chrome.
flatGridColumns gridColumns === 2 ? 1 : gridColumns The implicit flat bucket: the whole form when there is no x-layout, plus the trailing group of fields no group names. It is 1 at the default, which is the pre-grouping renderer's single column. When a host sets gridColumns, this follows it, so gridColumns: 12 alone is enough. A host can also set it directly.
x-colspan 1 Clamped to the column count of the grid it sits in. A span wider than the grid takes one full row instead of widening the grid.

Both properties are bindings, so changing one re-lays the form. createFieldGrid(chromeItem, fieldsOf) no longer takes a columns argument; the grid binds gridColumns itself.

Default = unchanged layout. With both properties left alone, every grid keeps its old column count and every pre-existing forms test passes as before. One behavior is new at the default: x-colspan is now clamped to the grid's column count. Previously, an x-colspan of 2 on a field in the 1-column flat bucket was passed through unclamped.

Tests

The new src/qt/forms/tests/tst_DynamicFormGridColumns.qml has 9 cases. It covers:

  • the defaults
  • gridColumns: 12 on flat, section, tab-set and chrome-hosted grids, including where the fields actually land (two 6-span fields share a row)
  • the clamp
  • setting flatGridColumns on its own
  • re-layout when the property changes

Mutation checks (actually run):

Break Red
Every grid set back to a fixed 2/1 columns 5 of 9
Span clamp removed 5 of 9

Local run on MSVC / Qt 6.11.1 with QT_QPA_PLATFORM=offscreen: forms_qml_logic 405 passed, 0 failed.

Independent of #822; the two touch different parts of DynamicForm.qml.

🤖 Generated with Claude Code

…a grid of its own

Every field grid was hard-coded: two columns per section and tab set, one
for the implicit flat bucket, and a literal 2 passed to the grid created
inside a host's section/tab-set chrome. A host whose UI kit lays forms out
on a 12-column grid could declare x-colspan but never get the grid it
counts against.

`gridColumns` (default 2) now sets the columns of every section, tab-set and
chrome-hosted grid. `flatGridColumns` sets the implicit flat bucket's: 1 at
the default -- the pre-grouping renderer's single column -- and following
`gridColumns` once a host sets that, so `gridColumns: 12` alone puts the
whole form on a 12-column grid. A field's x-colspan is clamped to its grid's
column count, so an over-wide span takes one row instead of widening the
grid. createFieldGrid() loses its `columns` argument; the grid binds
`gridColumns` itself.

With both properties at their defaults the layout is unchanged; every
pre-existing forms test passes as before. The new tst_DynamicFormGridColumns
.qml (9 cases) pins the default, the host grid on flat/section/tab/chrome
grids, the clamp and re-layout on change; fixing the grids back at 2/1
reddens 5 of them, dropping the clamp another 5. forms_qml_logic: 405
passed on MSVC / Qt 6.11.1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Yaraslaut
Yaraslaut merged commit abd3345 into master Sep 25, 2026
27 checks passed
@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant