forms(qml): DynamicForm.gridColumns -- a host lays the fields out on a grid of its own - #823
Merged
Merged
Conversation
…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>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / why
All of DynamicForm's field grids had fixed column counts:
2A 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
gridColumns2createFieldGrid()creates inside a section/accordion/tab-set chrome.flatGridColumnsgridColumns === 2 ? 1 : gridColumnsx-layout, plus the trailing group of fields no group names. It is1at the default, which is the pre-grouping renderer's single column. When a host setsgridColumns, this follows it, sogridColumns: 12alone is enough. A host can also set it directly.x-colspanBoth properties are bindings, so changing one re-lays the form.
createFieldGrid(chromeItem, fieldsOf)no longer takes acolumnsargument; the grid bindsgridColumnsitself.Tests
The new
src/qt/forms/tests/tst_DynamicFormGridColumns.qmlhas 9 cases. It covers:gridColumns: 12on flat, section, tab-set and chrome-hosted grids, including where the fields actually land (two 6-span fields share a row)flatGridColumnson its ownMutation checks (actually run):
Local run on MSVC / Qt 6.11.1 with
QT_QPA_PLATFORM=offscreen:forms_qml_logic405 passed, 0 failed.Independent of #822; the two touch different parts of
DynamicForm.qml.🤖 Generated with Claude Code