Design spec for morph::qt_quick::Backend (include/morph/qt_quick/backend.hpp) and
morph::qt_quick::Components (include/morph/qt_quick/components.hpp): the view tree's widgets as Qt Quick items,
and the application's own QML components beside them. The code is in src/qt_quick/; the QML is the private module
MorphUi (src/qt_quick/qml/).
Read this before changing a MorphUi component or a widget class. The contract the backend implements is
../ui/backend_contract.md; what mounts on it is ../ui/view_tree.md;
the frontend around it is frontend.md.
- Shape
- Several mounts
- Packaging
- Widgets
- User actions
- Kinds
- Containers and lists
- Keys
- The spotlight
- Layout and theme
- Components
- Tests
- Design decisions
- Not yet
QQmlEngine engine;
QQuickWindow window;
qt_quick::Components components{[](qt_quick::ComponentFailure const& failure) { /* report */ }};
qt_quick::Backend backend{engine, *window.contentItem(), {.components = &components}};
auto screen = interpreter.mount(document, params, backend); // or ui::Mounted{runtime, backend, view}Backend(engine, host, options)implementsui::IViewBackend. Every root a mount makes is appended to one column the backend adds tohost, top to bottom. The backend belongs to its engine's thread, and every widget it makes is destroyed before it.Backend::itemOf(widget)is theQQuickItema widget shows, for a host that embeds a screen or a test that drives one; null for a widget another backend made.BackendOptions::componentsis the restyle map and the custom components.Backend::widthClass()is the host's width inTheme.unitWidths, classed byui::widthClassOf.MorphRootsreports that width in units (widthUnits) through its relay whenever it changes, from a resize or a theme with another font, and the context re-classes it there, on the GUI thread and never inside polish; a change setsTheme.touchTargets(true whilecompact) and calls thesetOnWidthClasslistener.Themeis one per engine, so two backends of different widths in one engine share whichever class was written last.
An application with a shell of its own (a tab workspace, a split view) shows several screens in one window: each
page item of its shell is a host, with one Backend per page, and every root that backend makes is appended to the
column it adds to that page.
| Shared by every mount | Per mount |
|---|---|
ui::Session (cache, locale, translations), reactive::Runtime, Dispatcher, QQmlEngine, qt_quick::Components (restyles, host and bundle components), the Theme singleton (one per engine) |
qt_quick::Backend and its context (the per-type component cache), ui::DocumentScreenHost (its interpreter, close guard, application host and diagnostics callback), the screens and their handles |
- A restyle is resolved per
Backendwhen it first makes the type, so a restyle mapped after a backend made that type reaches only backends made later, and that backend keeps the component it made. Restyles are mapped before the first backend makes anything: inFrontendConfig::onEngine, or before the application builds its backends. - Every
Backendis destroyed before the engine, and everyDocumentScreenHostbefore theSession. Destroying one mount (its screens, its host, its backend) leaves the others working. - A mutation on one page applies its effects through the shared session, so a query another page shows refreshes.
- Nothing new is refused: a
DocumentScreenHostalready needs a backend and a document lookup.
morph::qt_quick is a compiled STATIC library behind MORPH_BUILD_QT_QUICK (default off). It needs MORPH_BUILD_QT,
for QtExecutor, and Qt 6.5+ Quick, QuickControls2 and Qml; configure fails naming the missing option. The QML
is the static module MorphUi (qt_add_qml_module, no plugin, no C++ types) in a target of its own, so morph's
warning set does not reach Qt's generated sources; its resource objects are linked into every executable that links
morph::qt_quick, and the backend loads each component with QQmlComponent::loadFromModule("MorphUi", …).
The public headers hold declarations only, so include/morph/qt_quick has no branch-coverage records and no floor
in scripts/check_branch_coverage.py. It installs and exports as component qt_quick, with the module's object
libraries; morphConfig.cmake finds Qt 6.5 Core Gui Qml Quick QuickControls2 for it.
Each widget class (src/qt_quick/kinds.hpp) owns one item made from its kind's component, and:
- writes what the item shows. A setter writes a property of the item, or of the control inside it, and does
nothing when the item already shows the value, so a re-asserted text keeps its cursor and its input-method
composition. State the user can change — a field's text, a check mark, a marked option, a slider's value, an open
overlay — is read back from the control itself, never from a property C++ last wrote, because the user may have
changed it since. A setter writes only a property the item declares: a name it does not declare would become a
dynamic property that no binding reads, so the write is refused and reported once per QML type and name, through
the
Componentscallback andfailures()(MorphText does not declare the property `x`; the write is refused), or onstd::cerrfor a backend without components. It is reported rather than thrown because writes also run from Qt signal handlers and from a table restriping its rows while one is destroyed, where an exception cannot pass. The placement and scheme a container writes into each child (fillsWidth,fillsHeight,inheritedScheme) are offered instead: everyMorphUiitem declares them, and a custom component takes part only if it does. - is reached through an
ItemBase. The common properties ofui::Widget(visibility, enablement, layout hints, drag key, drop target, accessible name and role, test id as the item'sobjectName, tooltip, surface, chords, focus) are one implementation for every kind;FieldItemWidgetaddsreadOnly,required,errorsandstale. - leaves the scene when destroyed. The destructor releases the widget's handlers at once, takes the item out of its container, hides it and deletes it later: QML may be running one of the item's own handlers, and the handlers hold the screen's scopes, which must not outlive it.
- is one accessible node. The node assistive technology and an automation driver see carries the document's
a11yname and role, falling back to the kind's own text and role, and the test id as bothobjectNameand, on a Qt that has the property,Accessible.id. A role the document names maps to Qt's:groupGrouping,headingHeading,textStaticText,buttonButton,edit(ortextbox) EditableText,checkboxCheckBox,listList,tableTable,chartChart,statusStatusBar, and the further nameswidget.cpplists; an unknown name keeps the kind's role. For most kinds the node is the widget's item. A button is a Button named by its label, with the press action, and a text is StaticText named by its text; the control inside either isAccessible.ignored. A key-value list is one node per pair, named"<caption>: <value>". - an input's node is its control. For a text input, text area, date input, select, check box, slider and file
picker the node is the Qt Quick Controls control a driver focuses and types into or sets, because its text or
value interface and its focus live there; the widget's item names it in
accessibleItemand isAccessible.ignored. The control binds the item'saccessibleName,accessibleRoleand its messages asAccessible.description, andshowTestIdwrites the test id onto it as well as onto the item, whoseobjectName, which each context'sWidgetIndexfiles the widget under (a test'sfindWidgetreads every context's index; a spotlight reads only its own, so the inspector window's items are never its target). So(name, role)and the test id resolve to the same single node. Kinds' own roles are EditableText for the text kinds and the file picker's path, ComboBox for a drop-down select, Grouping for a radio select, CheckBox and Slider. A drop-down the document names no name reads the option it shows. A ComboBox node has no value of its own, so the option a drop-down shows is the value of its one child, the style's text field, which the select declares EditableText from C++ (QQmlPropertyonAccessible.role, since QML writes an attached property only on the item that declares it); a named drop-down keeps its name and still reads the option there. A check box reads its label. A radio select's group carries the name, and each option is a RadioButton named by its label, with the press action. A select's hidden presentation is ignored, because a hidden item stays in the accessibility tree. The file picker's button is a Button node of its own. Each control declares its name and role itself: Qt Quick Controls makes a control an accessible node of its own accord only while the platform's accessibility is active, and on a platform with no accessibility bridge, such asoffscreenon Qt 6.8, it never is. - draws spans as escaped rich text, built in QML.
TextImpl::setSpanswritesMorphText'sruns: one map per run,{text, strong, mono, tone}, with each run's text already throughQString::toHtmlEscaped.MorphWidget.runsHtml(runs)builds the markup from them as the label is drawn: the runs inside one<span style="white-space:pre-wrap">(rich text otherwise folds a line feed and a run of spaces into one space), a strong run atTheme.strongWeight, a mono run in afont-familynamingTheme.monoFamilies(each family escaped for a quoted CSS string), a toned run incolor:the tone's colour in the widget's scheme. The markup reads the theme and the scheme when it is evaluated, so a theme applied after the mount restyles the mounted runs. Whilerunsis not empty the label shows the markup asText.RichText;setSpansalso writestextas the runs' text joined, which the accessible name andshownTextread, andsetTextclearsruns, so a plain text never goes through HTML.MorphBanner, a key-value item's value and a dialog's or drawer's description (descriptionRuns) do the same. Spans are the oneRichTextpath. - draws text as plain text. Every
LabelandTextthat shows a document's or a value's text setstextFormat: Text.PlainText: the default,Text.AutoText, draws a string thatQt::mightBeRichTexttakes for markup as styled text, so data holding<font>or<a href>would be drawn as markup. The Basic style's own content items read markup too and have notextFormat, so a button's, a collapsible's and a menu entry's content is aMorphPlainContent(the control's icon, then its text asPlainText), a check box's and a radio button's content is aPlainTextTextpast the indicator, a drop-down's options are delegates with that content, a tab's content is aPlainTextText, and a widget's tooltip is aToolTipof its own, made the first time it has one, whose content is aPlainTextText. - takes no focus out of reach.
focus()on a widget that is hidden or disabled, or inside such a container, does nothing; a widget that becomes hidden while focused gives its focus up.
QML reports what the user did through one relay per widget: the component calls host.fire(event, payload), or
host.ask(question, payload) when it needs an answer (whether a drop target takes a key, whether a chord is
declared). The relay calls a copy of the handler registered under that name, so a handler may destroy its own
widget; once the widget is destroyed the relay calls nothing, even for input QML delivers later; a handler that
throws is logged and goes no further. Only the user's own actions fire: Qt Quick's textEdited, toggled,
activated, moved and clicked signals, never a property change a setter made.
| Kind | Component | Shows | Reports |
|---|---|---|---|
| Text | MorphText |
a label in a text role, or its spans (below): a heading in Theme.headingFont, a section in Theme.strongFont, an overline (role 9) in Theme.overlineFont in scheme.muted (Theme.strongFont unless Theme.overlineCaps, else the small size, strong, Font.AllUppercase, letter-spaced by 0.05 times the small size; built whole with Qt.font, and Theme.figuresOf copies its capitalization and letterSpacing, so a tabular-figure column keeps the capitals; the accessible name stays as written), a caption (role 10) in Theme.captionFont in scheme.muted, a label (role 11) in Theme.fieldCaptionFont (Theme.captionFont unless Theme.fieldCaptionCaps, else the small size, strong, Font.AllUppercase, letter-spaced like the overline; the accessible name stays as written) in scheme.text, a mono text in Theme.monoFont on one line, elided at its end (wrapMode: NoWrap, elide: ElideRight) with its full text as the tooltip while it is elided and the node gives none (MorphWidget.tooltipText); a text in a table column whose wrap is false is drawn so too (singleLine, set by the row); runs are rich text, which the label does not elide, so a one-line text with runs (singleLine) cuts them itself (fittedRuns: the run the width ends in is cut with an ellipsis in its own face and the runs after it are dropped), and runs without singleLine wrap with their sentence, a mono role included, the rest in the body font; the width a text asks for is the widest line's advance in the text's current font plus 1 px, and a one-line text elides by that font, so both follow a role or a theme font set after the text; a run is measured in the face and at the size it is drawn in (the label's own size, with the strong weight for a strong run and the mono families for a mono one), so a run in a heading or a caption is as wide as it draws; wrapMinimumWidth is the widest unbreakable segment (measured by Theme.textMeasure, below, each run in its drawn face) plus the same pixel for a text that wraps, and the width of the line for one that does not, which a wrapping row counts as the text's minimum (shrinkWidth); a text that wraps is also given that width as its contentMinimumWidth, so a stack or a panel holding one is raised with it, and a one-line text has none; setAlign writes textAlign (Qt.AlignLeft, AlignHCenter or AlignRight) and ownAlign; the label's horizontalAlignment follows textAlign and Qt mirrors it under LayoutMirroring, and a table or grid row writes its column's align into textAlign only for a cell without ownAlign; the required mark follows the end of the last line where the alignment put it (lastLineEnd adds the spare width the label's effective alignment moves the line by); the colour is the node's tone when it has one (MorphWidget.toneOf(tone), whatever the role), else MorphWidget.textColorOf(role) (the scheme's muted colour for muted and section, error and success theirs, the text colour otherwise), which a restyle reads |
— |
| Button | MorphButton |
a Button; shape: round (the round property of every widget) gives corners of half the height, a width of at least the height and a surface background of the same shape; shape: square (square) keeps the theme's corners, drops the least width, pads the sides by Theme.spaceOf(1), draws a strong caption at the body size and is at least as wide as tall (a glyph alone gives a square of Theme.targetHeight); a push button with no label, an icon, and no shape of its own is drawn so under Theme.iconOnlySquare; size: small (small) has Theme.spaceOf(1) side padding, no least width, a strong label in Theme.smallPixels and the height Theme.smallButtonHeight (button.smallTouchHeight while touchTargets holds and it is set, else Theme.targetHeight; button.smallHeight, else Theme.controlHeight, otherwise), which may be above or below the control height; a round button's MorphButtonBackground is min(height, width) high and centred, so it is a circle when placed narrower than tall, and its focus and selection rings follow; a push button's caption, and a text input's, text area's, date input's and select's text (a segment's too, the marked one strong), draw through Theme.controlFontOf(weight): the body size, or Theme.touchTextSize while touchTargets holds and it is set, with the prominent input, a mono control, a small button, an item-style button, a popup list and the labels of radio selects left at their own sizes; a strong caption (filled, small or square) draws at Theme.buttonWeight, not Theme.strongWeight; a disabled button (the widget's enabled false) draws its caption and icon in Theme.disabledText, a push button on Theme.disabledFill with a 1 px Theme.disabledBorder outline whatever its emphasis (no dashes, no hover or press shading), a ghost button on no fill, and an item with its own fill and the caption grey; mono draws the label in the mono role's families; weight (captionWeight, 0 keeps the theme's) sets the caption's weight in place of Theme.buttonWeight (or normal), through the same weight snapping as every font (Theme.fontOf, Theme.monoFontOf). On a surface whose border.style is dashed a framed button's border is a MorphDashedOutline (dashedOutline) and its border.width is 0. emphasis 4, danger outlined, drawn as a normal button whose background border is scheme.errorBorder and whose label is scheme.error; its icon drawn as the control's icon when the theme's icon set names it (../ui/theme.md). The icon is drawn in the caption's colour (Theme.iconSourceIn(icon, palette.buttonText)): every currentColor in its SVG becomes that colour, and an SVG without currentColor is drawn as it is. A push button with no label whose icon the set does not name is never blank: MorphPlainContent (iconName, fallbackText) draws, in order, a MorphChevron (navChevron) for nav.back and nav.forward, the glyph Theme.iconGlyphs[icon], then the button's accessible name. style 1, a list item: it fills its line (fillsAcross), its content an icon and a left-aligned label padded by Theme.spaceOf(3), no border, a clear background that is scheme.neutral while hovered or pressed; while selected (itemSelected), the scheme's selection colour and, unless the surface's list.selection is fill (scheme.listSelectionFill), a 3 px accent bar at its leading edge; under fill there is no bar. Either way its label and icon draw in the scheme's selectedText: color.selectionText where the surface has one (hasSelectionText), else its text. A selected push button (style 0) keeps its frame, size and label: its background draws a 3 px scheme.accent ring outside its border (selectionRing, with radius radius + 3) and, unless filled (primary, danger), fills with the item's accent tint, darkened while hovered or pressed; a focused one keeps its scheme.focus border inside the ring. Once told selected it is Accessible.checkable, with Accessible.checked following selected; the control itself is not checkable, so a click the document does not answer leaves it checked. style and selected are part of the button's restyle API. An item with content: hasContent turns the content column into the Button's content item, so the content is inside the button and a press anywhere on it is the button's, and the background's tint and bar span its height. The content is handed contentScheme, a scheme whose every role is bound to the button's scheme except text, which is the scheme's selectedText while the item is selected and its text otherwise, so the content's Normal text follows the selection with nothing re-adopted |
click, Space or Enter |
| TextInput | MorphTextInput (single line, password), MorphTextArea (multi-line) |
a TextField / TextArea; a single-line field shows its text from the start while it is not focused and scrolls to its cursor while it is (autoScroll: activeFocus), so a field narrower than its text never rests on the text's end; while it has neither the focus nor a selection, is not masked and its contentWidth is wider than its text box, a MorphFieldElision label draws the same text with Text.ElideRight over the editor's text box (the same left and top padding, width, available height, alignment and font, so the first baselines coincide) and the editor's color is transparent, the one textColor being drawn by the label instead; the value, the accessible node and every event are the editor's, the elided form is never written to text, and while the label is cut the widget's tooltip is the whole text unless the node gives one (a selection that outlives the focus, as a popup's or a context menu's leaves it, is drawn by the editor, since a transparent text would leave its highlight and glyphs over the label's; a window in the background shows an edited field cut, and a field scrolled to its tail by an edit shows its start once it loses the focus); every input's left and right padding is Theme.inputPaddingX (input.paddingX), grown on the leading side by the icon and prefix and on the trailing side by the unit, and a text area's top and bottom padding is half of what the control height leaves over a line, so its first line sits where a single-line input's text sits, and its natural width is its insets alone (the style's also counts the wrapped text, which is as wide as the area, so an area in a content-sized container would size from its own width); a single-line field draws its unit as a muted trailing label inside the field, its right padding grown by the label's width, draws its icon as a leading image inside the field, drawn in the accent when its SVG paints currentColor (its left padding grown by the image's width; no themed icon for the name reserves no space), and carries decimals for a kit (the stock input draws nothing from it); a prefix as a muted label at the leading edge after the icon, the text's left padding grown by its width, and announced before the field's description; mono draws the text and the placeholder in Theme.monoFamilies; wrap: false (MorphTextArea only) sets the area's wrapMode to TextEdit.NoWrap, so a long line stays whole and the area scrolls sideways, and a single-line field refuses it; the placeholder is drawn in scheme.placeholderText (the surface's color.placeholder, else its muted colour); align: end sets textAlign to the right edge and tabularFigures; while prominent, its text at the heading size in Theme.strongWeight (never a literal weight: a family without it can match an italic face), in the mono role's face with mono, its background the touch height on every window with a 2 px scheme.accent border at all times and, while focused, a 3 px ring of Qt.alpha(scheme.accent, 0.2); a tone or errors win over the accent |
each edit's whole text; Enter commits then submits (single line); focus leaving after an edit commits |
| Checkbox | MorphCheckbox |
a CheckBox with no vertical padding of its own: it is as tall as its label's line or its indicator (boxIndicator, a MorphCheckIndicator), and at least Theme.targetHeight while the window is compact; the container's gap spaces the rows. It has no side padding, so the indicator starts at the widget's edge, and the label follows the indicator by Theme.spaceOf(2). The indicator is Theme.unitHeight square, and Theme.touchHeight / 2 while Theme.touchTargets holds, as the table's select column's is |
the state toggled to |
| Select | MorphSelect |
a drop-down ComboBox on MorphInputBackground: its value (the contentItem) starts Theme.inputPaddingX in from the border and stops short of the chevron, a themed chevron indicator (select.open/select.close, else nav.expand/nav.collapse, flipping with the popup; the fallback glyph in scheme.muted), and on a dashed surface the field's plain border is a MorphDashedOutline. Its list is a Popup in MorphPopupBackground, padded by Theme.spaceOf(1), at most eight options tall and then scrolling; an option is Theme.targetHeight − 2 tall with radius.badge corners, fills with the card scheme's hover while hovered or highlighted, and the current one is drawn at Theme.strongWeight with a ✓ in the accent at its trailing edge. Otherwise RadioButtons, or a segmented row: Buttons on a scheme.neutral track with Theme.radiusControl and a 2 px inset, the marked one on scheme.surface with a border, each Accessible.RadioButton with focusPolicy: Qt.NoFocus, the track the one focus stop (Accessible.Grouping) taking Left and Right; Theme.targetHeight − 8 tall, the touch height while Theme.touchTargets holds; a stretched one shares its width equally among the segments |
the chosen option's index, which C++ turns into its key |
| Menu | MorphMenu |
a bar of top-level entries (an entry's icon is drawn in its text colour when its SVG paints currentColor; an icon-only trigger the set does not name shows Theme.iconGlyphs[icon], else its accessible name); with buttonStyle, one button drawn as a MorphButton (triggerLabel, triggerIcon, triggerEmphasis; square, as a square button, while Theme.iconOnlySquare holds and the trigger is an icon alone; its caption Theme.controlFontOf at Theme.buttonWeight for a filled or square trigger and at the normal weight for emphasis 0, 3 and 4, as a MorphButton's) that opens the top level in the popup (which takes focus while open, so Escape closes it), its item the one accessible node (ButtonMenu); a submenu opens in the popup, one level at a time; a separator is a MenuSeparator, a description a muted line under its Accessible.MenuItem entry |
the chosen entry's path |
| Popup frame | MorphPopupBackground |
the one frame of a popup that opens from a control: the card scheme's surface, a 1 px divider rule, radius.control and a shadow from elevation.popup below it; its scheme defaults to Theme.cardScheme. A menu, the date picker and a select's drop-down use it as their background, with MorphPopupPlacement: set when the popup is about to show and again when its width changes while shown, the popup goes under its control at the control's start when it fits in the window, else ending at the control's end, and margins of Theme.spaceOf(1) keep it inside the window. A menu bar records the entry that opened its popup (openFrom) and places it there; a menu entry's highlight is scheme.hover |
— |
| Column, Row | MorphStack |
a GridLayout flowing on the axis (once told setActionRow, a row of actions, its gap is Theme.actionSpacing, the theme's actions.gap while above 0, else step 2, in place of Theme.spaceOf(gap); this holds for a wrapping row too, between its children and between its lines, and a wrapping row gives no gap to a child with no width, which a non-wrapping one does), inset by Theme.spaceOf(paddingV) above and below and Theme.spaceOf(paddingH) at the sides; align and justify (the ui::Align and ui::Justify indices); once told divided, a stack that does not wrap draws a 1 px scheme.divider rule centred in each gap and takes that pixel into the gap (a column's rule spans its width, a row's its layout's height); once told selected (selectable) it draws a 3 px scheme.accent bar (selectionBar) at its leading edge, mirrored under right-to-left layout, with the leading corners of its surface's radius, over the surface's background and under the children, while selected; a selectable stack's default accessible role is Grouping in place of Client, with Accessible.selectable set and Accessible.selected following selected |
— |
| Grid | MorphGrid |
minColumnWidth (units, above 0 for a grid without tracks) makes place() show shownColumns of the columns: max(1, min(columns, floor((width + gap) / (minimum * Theme.unitWidth + gap) + 1e-6))), using that count for the cell walk, the column widths and the rows, while naturalWidth keeps all of them and the item's implicit height follows the rows placed (the binding runs from the width to the count to the height, and the implicit width never reads the count); place() lays every grid out in an item of its own, as the terminal does: a child's span is its columnSpan; align. With tracks ({kind, amount, align} each) each column is sized by its track; without them the grid has columns equal stretch tracks of weight 1, and its natural width is the columns times its widest cell (a spanning cell's width, less the gaps it covers, divided by its span), as the terminal's. So the columns do not follow their content, a grid given more height than its rows does not spread it, and a cell's minimum does not widen its column. A cell that fills its track stops at its own maximum width, at the track's start. A track's edges are whole pixels (Math.round of each track's left and right edge, so a spanning cell covers the rounded edges of its tracks): a cell on a half pixel is drawn with its far edge a pixel out, and a clipping ancestor (a dialog's scroll area) cuts its border off; a grid never reports an overflow, since a cell is given its track whatever its own minimum. place() runs again when the width, the column count, the tracks or the gap change, when the theme's unit sizes or spacing scale change, and, called by C++, whenever a cell's implicit size, visibility or span changes; across its track a label-width cell (fillsAcross false) keeps its natural width at the track's start, centre or end, and a text cell its textAlign |
— |
| Spacer | MorphSpacer |
space that fills the layout | — |
| Panel | MorphPanel |
a framed region with a title and padding; collapsible, with a MorphSectionHeader (below) flush with the frame's top and the content starting at the header's foot (the header row is a touch target tall already, so neither the padding nor the layout's spacing separates them), the padding applying at its sides and below it (a panel that does not fold keeps the padding above its content and the spacing under its title), and the header itself inset at least Theme.spaceOf(2) from the frame's sides whatever the padding; folded, it is its header row inside the frame, with no padding below and no spacing to the hidden content; no rule under the header. With no surface it is a card: it fills with Theme.cardScheme.surface, draws the card shadow unless it sits on a card, and PanelImpl::scheme() hands its content the card scheme; with a surface the widget draws the surface and the frame is a border only, and the surface's fill takes the frame's corner radius (frameRadius), so it does not show outside the rounded corners |
the collapsed state asked for |
| Scroll | MorphScroll |
a Flickable that scrolls the focused item into view, its content along a horizontal axis at least the viewport's width, with one bar on its axis made from its bar part (MorphScrollBar, a child of the flickable, where the attached ScrollBar lays it out); a vertical one whose content cannot be narrower than the viewport (needX, the content column's Layout.minimumWidth, wider by more than 2 px) lays the column out at needX, scrolls sideways too, and shows a second bar from the same part with policy: AlwaysOn |
— |
| Splitter | MorphSplitter |
a SplitView (a horizontal one without matching sizes places each pane by its own width in applyOwn: fixed in units, percent as a share of the split view's width, the rest by weight with content as weight 1, the heaviest taking fillWidth; every MorphWidget binds SplitView.minimumWidth/maximumWidth and the heights from its bounds, so a drag stops there; the shares are applied again as the width changes until the user drags, and when a pane's sizing changes; the splitter's natural width reads no width from a pane that is fixed (its units), a share or a stretch while its container sizes it, since such a pane's implicit width can follow the width it is given and the natural width would grow on every pass) whose handles are made from its handle part (MorphSplitterHandle); the splitter sets each handle's axis and scheme, and leaves a handle's implicit extent along the axis between two panes. The stock handle is 6 px thick, in scheme.border and scheme.controlBorder while hovered or pressed, with a grip centred on it: 2 px across the axis, min(28, length / 3) along it, radius 1, in scheme.neutralDot |
the panes' sizes once a drag ends |
| Slot | MorphSlot |
its children inset by contentInset (0 unless a tabs node gives its page the page padding), packed at the top unless one stretches vertically. A scrollable slot scrolls only while its content does not fit, in a Flickable with MorphScrollBars made from its bar part, and the focused item is kept in view on both axes (reveal). With inset for contentInset, needX the column's Layout.minimumWidth plus 2 * inset and needY its implicit height plus 2 * inset: overY is stretchFloor + 2 * inset > height while a child stretches down and needY > height + 0.5 otherwise, overX is needX > width + 2, and the slot scrolls (clip, flick.interactive) while either holds. flickableDirection follows the axes that overflow; flick.contentWidth is needX and contentHeight the content's height plus the padding on an axis that overflows, the viewport's otherwise; the column lies at (inset, inset), needX or the viewport's width less 2 * inset wide, and is max(flick.height - 2 * inset, stretchFloor) tall while a child stretches down. The vertical bar shows while overY, the horizontal one (always on) while overX. The column's childBleedInset is contentInset, so the page's bleeding children reach the slot's own edges. A slot reports content wider than itself, scrolling or not (page) |
wheel, drag |
| Tabs | MorphTabs |
with inset, the TabBar and More start Theme.spaceOf(inset) in and each page slot is padded by it on every side, inside its own scroll (pages has no margins; MorphTabs binds each page's contentInset to pageInsetPx as the page is added), or by Theme.spaceOf(pageInset) once pageInset is written; the mount lays each page out stretch both ways, so it fills the area under the strip and a short page sits directly under the strip's rule instead of centred; with stripSurface, the strip row is drawn on the surface's background across the whole width (stripSurface), under the rule. A TabBar over the page slots, one TabButton per caption (the chosen tab's label in the text colour over a 2 px accent underline, the others' muted) (the Repeater's model is the caption count, so a relabel keeps the buttons, the highlight and the focus), the chosen tab kept wholly in view (select calls the bar's positionViewAtIndex(index, ListView.Contain) once the bar is laid out, and again when its width changes, so a tab chosen before the first layout is placed too), Theme.spaceOf(3) above them (none while the strip is inset: the pages' own inset is the gap), each TabButton at least Theme.targetHeight tall, the control height, and 44 px while the window is compact; barShown false hides the bar and gives its height to the pages, and its focusTarget is then the pages, so a hidden bar never holds the keyboard focus. When the tab buttons together are wider than the row, only the leading tabs that fit beside a More button stay in the bar, as many as fit (each tab is Theme.tabInsetX in from its label on both sides, and More too: the theme's tabs.paddingX, or Theme.spaceOf(3) while it is 0. Each tab after the first also draws Theme.tabGap (tabs.gap) in from its leading edge, as a leftInset of its own button that its padding includes, so the gap is inside the next tab's hit area, a hidden tab at width 0 takes none, and the active underline spans the label and its padding without the gap; More takes the gap while a tab is shown before it, and moreWidthFor(label, shown) adds it only for shown > 0, so More as the first item stands at the padding. The underline is named tabUnderline. More's menu opens at the button's left, which is the gap before its label), and More follows the last shown tab with the 1 px rule under the tabs running on past it; a tab past the fit is visible: false and has no width, so it leaves the bar, the focus chain and the accessibility tree, while bar.count stays the tab count and bar.currentIndex the chosen tab's index. More (more) is a sibling of the bar, an Accessible.Button named by its shown label (moreLabel and ▾, or, while the chosen tab is one of the menu's, that tab's label with the active underline), and is measured at its widest label so what fits never depends on the label it shows. It opens a MorphPopupBackground menu of the hidden tabs (Enter, Space or Down on it, or a click); choosing an entry sends the tab's own index as a click on its button does. Right on the last shown tab focuses More, and Left on More goes back. The fit is recomputed on every width change |
the tab clicked, or a menu entry |
| Dialog | MorphDialog |
a modal Popup, centred, drawn as the theme's card surface (color.surface, its border, radius.card and a shadow, dialogShadow, from elevation.dialog, which is elevation.card while the theme sets none; a MorphShadow, which draws the outline offset and grown by the token, blurred as a Gaussian of deviation blur / 2 in 16 nested rounded rectangles whose alphas composite to the falloff, the strength reached after the k-th layer growing as the square of its position so the outermost layers add less than one 8-bit level and the shadow ends in no visible step, so it needs no offscreen texture; only a dialog and a drawer draw one) with Theme.spaceOf(4) padding, whatever surface encloses the node: its content and title draw with the card's scheme; its footer item, under the content, holds the footer (a MorphFooter: its children in a row against the right edge, Theme.actionSpacing apart), shown only while it holds something. With sheet the popup is placed in the overlay's coordinates and fills it, its footer (MorphFooter.stretching) filling the sheet's width with its actions sharing it equally, so a lone action spans the footer, with no margin and radius 0 and no shadow; a head row holds a flat button (objectName sheetDismiss, its text and accessible name dismissLabel) and the title, and the content scrolls between the head and the footer. The sheet's head draws the title (sheetTitle, plain characters, never markup) centred on the sheet, a trailing item as wide as the dismiss button balancing the row, and a head rule always shows under the head (under the description where there is one). A restyle declares sheet, dismissLabel, headNote, footerNote and closeButton, or it stays a centred popup with no dismiss control. Outside a sheet the title sits in a row (titleRow) with the head note (headNote, muted, trailing) and, with closeButton, a flat dismiss button (headClose, labelled dismissLabel) after it; a drawer draws the same row. The footer note (footerNote, muted) leads in the MorphFooter, above the actions while the footer stretches, and a note alone makes the footer show. The title is drawn in Theme.headingFont (the heading size at the strong weight), a sheet's too. While the footer holds an action, a 1 px Theme.dialogRuleShown rule (footerRule; color.dialogRule, else the card scheme's divider) sits above it, outside the ScrollView and in its height cap. The head's and the footer's rules span the overlay, edge to edge: each takes negative layout margins of the popup's side padding, so it reaches the border. A description is a muted, wrapping label under the title (given as runs, descriptionRuns, it draws their markup), then a 1 px Theme.dialogRuleShown rule across the overlay (headRule), both outside the ScrollView, whose height cap subtracts them and their spacing. Each rule stands Theme.spaceOf(3) off the item above it and the item below it (its layout margins are that step less the column's spacing), and while the footer shows the popup's bottom padding is Theme.spaceOf(3), so the actions sit that far from the edge. A Popup takes no Accessible attached property, so the content column is the overlay's accessible node (accessibleItem): Accessible.Dialog, named by the title or the node's a11y.name, described by the description |
Escape or a press outside, as a dismissal; a sheet closes only on Escape or its dismiss button, either a dismissal |
| Drawer | MorphDrawer |
a modal Drawer on the start or end edge, drawn as a dialog is but square against its edge, with a dialog's title size, shadow and divider-coloured head and footer rules spanning the drawer and standing off their neighbours as a dialog's do; it cannot be swiped open; its footer as a dialog's, at the bottom |
as a dialog |
| Toast | MorphToast |
a non-modal, non-dimming Popup near a corner of Overlay.overlay, closePolicy: Popup.NoAutoClose; show(text, tone) is a QML function call, not a property write, so a repeated call with the same text and tone still restarts the dismiss Timer and reopens the popup if it closed |
— |
| Popover | MorphPopover |
a non-modal, non-dimming, focus-less Popup whose parent is the container the popover is mounted in, placed at the container's leading edge under its box (x: 0, y: parent.height), as wide as widthUnits units or the container; it takes no room in the container's layout; closePolicy is a press outside the container, which reports a dismissal (Escape is the focused field's, since a focus-less popup receives no keys); show(open) opens and closes it without one; drawn as the theme's card |
— |
| Busy | MorphBusy |
a BusyIndicator and a label, both shown only while active (inactive, its implicit size is 0×0) |
— |
| Table | MorphTable, a header over a MorphTableHeaderBackground, rows MorphTableRow over a MorphTableRowBackground |
column headers over rows (each header in Theme.tableHeaderFont, which the column widths are measured in); a fixed(n) column is n units plus the cell padding on both sides, a unit being Theme.unitWidth or, in a column whose role is mono, Theme.monoAdvance (the mono face's character advance), so an identifier fits whole; a row sets each cell's singleLine from its column's wrap. No column is narrower than its header, except a stretch column with shrink, whose floor is the 8-unit minimum alone, so its header elides. A table whose columns are wider than it scrolls sideways in hflick, with a bar made from the table's bar part (the scrollBar part, a child of hflick) that is always on while hflick is interactive: the table's implicitHeight grows by the bar's, and a virtualized table's rows end above it. A table row offers each of its cells honoursContentMinimum: false, so a cell is cut at its column rather than pushing the row out of line with the header |
selection and activation, below |
| DateTimeInput | MorphDateTimeInput |
yyyy-MM-dd or yyyy-MM-dd HH:mm in the display zone, or its pattern (typed text is read in the pattern, then as ISO, and shown in the pattern once read; text neither reads is refused and the field shows its value again), shown from its start while the field is not focused and padded by Theme.inputPaddingX, cut by a MorphFieldElision label as the text input's is (tooltip included), formatted and parsed in C++ through the shared date-pattern functions; the placeholder is the pattern in lower case, xxx shown as +hh:mm; a calendar day is reported to C++ (pick), which writes it in the pattern with the field's time of day, and C++ writes back the day the calendar marks (chosen) |
the instant typed, once the user finishes; empty is cleared |
| Slider | MorphSlider |
an integer Slider |
the rounded value moved to |
| FilePicker | MorphFilePicker |
a path and a button opening Qt Quick Dialogs' FileDialog, both in Theme.controlFontOf at the normal weight |
the local path picked |
| Badge | MorphBadge |
a tag (its icon drawn in the label's colour when its SVG paints currentColor): the label in Theme.smallStrongFont on the tone's fill, with radius.badge corners, no border, and 1 px above and below it; while outline, the fill is scheme.surface, the border 1 px in the tone's outline colour (controlBorder when neutral) and the text the tone's colour (scheme.text when neutral); quiet is an outline badge whatever its tone: the border is controlBorder and the text scheme.muted (the tone colours only the icon); a removable badge is drawn as a chip instead: controlSurface with a 1 px border (controlBorder when neutral, else the tone's outline colour), the body font, Theme.targetHeight − 6 tall, an inset of space.2 before the label, and a square ToolButton (remove, drawing close in muted, its accessible name removeLabel) that is the badge's focus target; shape: round gives corners of half the height and a width of at least the height; mono draws the label in the mono role's families; on a dashed surface an outline badge's and a chip's border is a MorphDashedOutline; naturalWidth is the side padding, the icon, the label's implicitWidth and the remove control, read from the parts and not from the row (which sums the label as drawn), and it is the badge's contentMinimumWidth, so a stack holding one is raised with it; a table sets elideToWidth on the label-width cell it places, and the label then has elide: ElideRight and a width of at most what the badge leaves it, the row is clipped, and the full text is the tooltip while label.truncated unless the node gives its own |
a badge's removal |
| Dashed outline | MorphDashedOutline |
a Canvas over its parent that strokes a rounded rectangle (radius, color, lineWidth, default 1) with setLineDash([3, 2]), repainting when its size, radius or colour changes; the outline of a button, an outline badge or chip and an input's plain border on a surface whose border.style is dashed, drawn at the device pixel ratio so it stays crisp on a dense screen |
— |
| KeyValue | MorphKeyValue |
captions beside their values in a grid, the caption column as wide as the widest caption, or while captionUnits is 0 or more exactly captionUnits * Theme.unitWidth, a longer caption wrapping at word boundaries and the pair growing to the taller of the caption and the value (the width is a number of units, read from no layout); while captionsAbove, a column of pairs, each caption in Theme.captionFont (as a form's stacked caption) and scheme.muted over its value; each value held at its widest unbreakable segment in the font it is drawn in (Layout.minimumWidth), and the kind's own contentMinimumWidth is, beside its captions, the caption column (captionUnits units, else the widest caption) plus two units plus the widest value segment, and above, the widest caption or value segment; inline captions keep Theme.bodyFont and, like the value, take Qt.AlignBaseline, so a caption shares its value's first baseline whichever of the two wraps and whatever face the value is drawn in, with a 1 px scheme.border rule Theme.spaceOf(1) from each side after every pair but the last. A toned value takes toneOf(tone) and Theme.strongFont; a value with spans draws the same rich text as a Text. Each pair is one accessible node named "<caption>: <value>", a value with spans by its runs' text |
— |
| Banner | MorphBanner |
a frame (objectName frame) filled and outlined in the tone's parts, with radius Theme.radiusControl, inset Theme.spaceOf(2) above and below and Theme.spaceOf(3) at the sides; the message (message), runs included, in the tone's colour (scheme.text for a neutral banner), a strong run strong in that colour; the action (action, in Theme.controlFontOf at the normal weight, as an outline or ghost button's) a ghost button (MorphButtonBackground with ghost), unframed with its label in the scheme's accent, a framed normal button under actionStyle button, and on a row of its own spanning the banner under actionStretch; under link the action is not a button but an <a href="action"> in the message's rich text (a run marked action, else one appended after the message), wrapping a span in the accent, underlined, whose label's linkActivated fires it, with an actionProxy (a 1×1 Item with the Button role, the action's label as its name, Tab focus, and Enter, Space and Accessible.onPressAction firing the action) that, while it has the focus, draws the link's markup on the focus colour; a dismiss tool button |
a banner's action and dismissal |
| Steps | MorphSteps |
numbered circles (round(1.7 × bodyPixels), a 1.5 px border) joined by 2 px connectors that share the width: a done circle is filled with the accent and holds a white ✓, a failed one is filled with error and holds ✗, the current one has an accent border and number, an upcoming one the controlBorder and a muted number; a connector is in the accent after a done step and controlBorder otherwise, and stands Theme.spaceOf(2) off the step before it and the one after it (its cell's least width grows by twice that); the label follows its circle in scheme.text while current and muted otherwise. Unlabelled, only circles and connectors are drawn. Each step is an Accessible.ListItem named by its label and, when current, done or failed, that state; the indicator is an Accessible.List named by the current step's label |
as the backend contract says |
| Progress, EmptyState | the component of that name; an empty state's action in Theme.controlFontOf at the normal weight |
as the backend contract says | an empty state's action |
| Chart | MorphChart |
one Canvas, below |
— |
| Collapsible | MorphCollapsible |
a MorphSectionHeader (below), the content directly below while open, with no spacing between them: a closed collapsible is as tall as its header |
the open state asked for |
| Section header | MorphSectionHeader |
the header of collapsible and of a collapsible panel: the title in Theme.strongFont flush with the content's leading edge, the node's header slot after it (above the toggle, so it keeps its own clicks), and a muted chevron (the theme's nav.expand / nav.collapse icon, else ▾ / ▸) at the trailing edge, drawn only while Theme.collapsibleMarker holds (collapsible.marker: none hides both the icon and the glyph and changes nothing else). The whole row is the toggle (toggle), at least Theme.targetHeight tall, an Accessible.Button named by the title with Accessible.expandable and Accessible.expanded following the open state where Qt has them (Qt 6.8 does not, so they are set at load rather than declared); Space and Enter toggle it as a click does. A header that folds nothing (a titled panel that is not collapsible) draws no chevron and answers no click |
the open state asked for |
| DropZone | MorphDropZone |
a framed DropArea for files |
the local paths of a drop it took |
- The chart.
MorphChartpaints the whole chart on oneCanvas, part ofQtQuick, which the frontend already links: Qt Graphs and Qt Charts are separate modules (a package for every build and the WASM client), andQtQuick.Shapesis a QML module to deploy, and a chart of a few hundred points paints in well under a frame.ChartImplwrites theChartDataas onechartmap of numbers and strings (a tone or clip as its index,-1for no tone, a gap asgap) and thesummarytext; the item repaints when either, its size or its scheme changes. The labels are painted too, inTheme.bodyFont: the axis labels (the lines' when three or more label the axis, else the ticks') right-aligned in a left gutter as wide as the widest,yLabelabove them; with ticks, each line's label at its right end, above the line; thexLabels in one row below the plot, each skipped when it would overlap the last one drawn, the newest always drawn; the legend below that for two or more series, each series' shape beside its label, aBarsseries' a bar-shaped swatch (a unit wide, 0.8 of a unit tall), a shape no marker has. It draws, in order: the bars of everyBarsseries; the lines (1 px on a pixel row's centre, so a line is one row of device pixels at any ratio; dashes 4 on 3 off, dots 2 on 3 off, in the tone's colour,mutedfor neutral); eachLineseries as a 1.5 px polyline inscheme.chart1tochart4, broken at gaps, when joined; its points, 5 px across, as a circle, square, triangle or diamond in token order; then over every series the clipped points (an open triangle at the edge, pointing out of the plot) and the marked points (a cross 10 px across, 2 px stroke, in the tone's colour) and the notes (the tone's colour, beside the point, flipped to its left near the right edge). A bar is a filled rectangle in its series' colour (its tone's for a marked point) from the baseline, which is 0 clamped into the axis, to the value; a group of n is0.8 × barSlotwide in plot pixels, each bar a nth of it and at least 1 px, the bars touching and in series order from the left, and where bars overlap the one whose tip is nearer the baseline is drawn over the other, the later series over the earlier on a tie. A reference line crosses a bar on top of it. A marked bar's cross is centred half a unit beyond its tip, a clipped bar's open triangle on the axis end, and a note beside that place. Its content size is 40 units by 8, so a chart in a stretching column is readable before anysizing. It isAccessible.Chart, named by the node'sa11yname or else the summary; the summary is the description only when the name is not, so a screen reader reads it once.shownText(), the probe'stextOf, is the summary. ACanvaspaints at the device pixel ratio, and the chart's tests run again atQT_SCALE_FACTOR=2(qt_quick_chart_scale_2). - Description and tone.
MorphFieldcarriesdescriptionandtone(theToneindex, 0 none). Adescriptionlabel under the messages wraps, is muted ortoneOf(tone), and counts in the field's height; the field'saccessibleDescription, which every control declares asAccessible.description, is the messages, then the description, then the kind'sannouncedUnit(a text input's unit), so a listener hears a value with its unit while the name stays the label.shownToneisErrwhile the field has errors, else its tone, and outlines the control:MorphInputBackgroundtakestone, draws its border in the tone's colour focused or not (focus shows as the 2 px width), and a 2 px ring of the tone's fill outside it as a siblingRectangle, since aRectangledraws nothing outside itself. A check box draws its indicator's border in the tone, a radio select each indicator's, and a slider its handle's. - Required mark. While a caption is drawn,
MorphField's mark sits on the caption's line, a space step after itscontentWidth, the caption elides short of it, and the control takes the field's whole width.MorphTextsetsmarkerFollowsTextand gives the end of its last line (textEndX,textEndY, recorded fromlineLaidOut; rich text reports no lines, so for spans the widest line's end on the last line) and wraps short of the mark. Otherwise the mark sits at the field's right edge beside the control, which gives up its width. - Captions.
MorphFieldcarriescaptionandlabelShown; whilelabelShownit draws the caption above its control and moves the control under it, and the field's implicit size takes it in. A text input, select and date-time input write both fromsetCaption. A restyle readscaptionwithlabelShownfalse to know its label is drawn elsewhere. (The property is notlabel:MorphCheckboxdeclareslabelfor its own text.) - Controlled inputs behave as the contract says: the control shows the user's action at once, as Qt Quick does, and the mount re-asserts the document's value in a later turn. A read-only check box, select or slider takes focus and puts its own state back when the user acts; a read-only text field reports no edit, commit or submit.
- Icons. A badge, an empty state, a menu entry and a button draw a node's icon from
Theme.iconSourcewhen the bundle's icon set names it, and the built-in text otherwise; a banner draws its tone's framework icon and its close button's, and a collapsible and a panel their chevrons, from the set when it names them. While the bundle declares a set, a node icon outside it is reported once per name (Context::checkIcon). - Dialogs and drawers open and close without a transition, so what the document says is what the window shows.
footeris part of their restyle API: a kit's dialog places the footer item where it wants, and a restyle that does not declare it is refused. A close bysetOpen(false)reports nothing; Escape or a press outside closes the overlay first and then reports the dismissal. - A date-time field that the user leaves holding text that names no instant reports nothing and shows again what it showed before.
A container keeps its children in the mount's order in C++ and appends each child's item to its content item. The
layouts follow the items' stacking order, so moveChild is one stackBefore/stackAfter of the moved item: the item
is moved, never made again, and keeps its focus, its selection and the text a user typed into it. A split view takes
and orders its panes through its own container API (addItem, moveItem, takeItem).
A forEach or a table is such a container, reconciled by the mount: a list change reaches the backend as the
mount's keyed operations — an append, a destroy, and the fewest moveChild calls (n minus a longest run already in
order) — and each of those is one operation on the Qt side. Nothing re-creates or re-orders a kept row's item.
Tables. A horizontal stack the mount makes inside a table is one of its rows (MorphTableRow). A row places its
cells by column index at the table's column widths — fixed units, the widest of the header and the column's shown cells
for content (as the terminal backend sizes it), each plus table.cellPaddingX a side so the padding never takes room
from the content, and for stretch its content plus a share of the rest (the contract's four steps over its natural, least
and floor widths, each with the padding a side and the header's at least 8 units, as an empty content column's; shrink
lowers the floor to the 8 units alone) — so a hidden cell keeps its column and the cells after it stay under their headers. A cell is
its column's width less table.cellPaddingX a side, except one whose fillsAcross is false (a badge, a check box, a
button), which is its implicit width at the column's start, centre or end, by the column's align. A cell that
declares textAlign (MorphText, MorphTextInput) is given the column's align as Qt.AlignLeft,
Qt.AlignHCenter or Qt.AlignRight, its label's or field's horizontalAlignment, which a right-to-left layout
mirrors; an end column's cells also set tabularFigures, drawing digits at one width (tnum) so numbers line up.
The header's label takes the column's alignment. Every cell keeps its implicit height, up to the tallest, and sits at
the row's top, centre or bottom by the column's valign; Stretch gives it the row's height. The header and the rows sit in a horizontal Flickable (hflick) as wide as the
columns: while they are wider than the table by 1 px or more it scrolls sideways, clips and shows a horizontal MorphScrollBar (a smaller excess is rounding: the stretch columns sum to the width that is left exactly, the last one not floored taking what the others leave, and the table's form of the layout's "a smaller shortfall is rounding" keeps it from scrolling); a table whose columns are wider than it by less scrolls not at all;
otherwise it takes no drag or wheel event, and it never takes a vertical one. The rows' own vertical Flickable
(flick) is, virtualized, what the header leaves of the table's height, and otherwise its rows' height. A content or stretch column's width is cached per column rather than recomputed
by rescanning every row on every change (columnCache; a stretch column also keeps its least width in leastCache,
which is read in the same way and written outside the widths binding, so no binding loop forms): a cell growing only raises its column's cached width; a cell shrinking, a row
leaving, or a cell's visibility flipping rescans that one column, since the cache alone cannot tell whether the row
that set its current maximum is still contributing. A cell's natural width is its widthFreeNatural where it gives one
(a table's and a wrapping run's are rounded up to whole pixels), else its implicitWidth, and its least width its shrinkWidth within the natural width.
A virtualized table reads its realized rows, and both caches only grow. MorphWidget.widthFreeNatural (default -1,
unknown) is what a widget asks for however wide it is laid out, for a widget whose implicitWidth follows the width it
is given: MorphText sets it from font advances (for runs that wrap, the widest of their lines, a run's line feeds
starting a new one), MorphTable sets it to the lead plus each column's natural width, read from the caches and the
headers, never from its own width, and MorphStack and MorphPanel pass it on while any shown child gives one (a row
sums its children's, a column takes the widest, with the gaps and the padding), so a table nested in a cell does not feed
its own result back to its parent's columns. A cell reports a change of its widths through measuredBy and
measuredIndex, which the table's row sets as it adopts the cell. MorphTableRow.place is re-entry-safe: placing a
cell can change its implicit width, which reports to the table and changes widths while place is still running, so a
call made then only asks for another pass, which the outer call makes with widths read afresh, at most three in one
call stack (placePasses counts them in tests); a row still unsettled after that places once more from the event loop. Either way, every row still places its cells again once a
column's width actually changes, since a widened column's cells all need their new x/width. A table is a Tab stop
(activeFocusOnTab) that hands the focus on to its current row, or the first; the focused row is the current one,
which its background draws and assistive technology announces with Accessible.selected. A click makes its row
current and focuses it, unless a control in a cell took the focus with the press; the TapHandler reports Ctrl and
Shift, which TableImpl::tapped reads as a RowClick against the anchor it keeps. The table's own keys
(MorphWidget.ownKey, after its chords) run while the table or a row holds the focus itself: the arrows, Home, End,
PageUp and PageDown move the focus between the shown rows, Shift with Up or Down marks the row left as the anchor
when there is none and selects the range, Space toggles the current row, and Ctrl+A (multiple only) selects every
row or clears them. A plain double click or Enter on a row activates it without toggling the selection. A range and
Ctrl+A run over setExistingKeys' keys in row order when the table virtualizes, and over the realized rows
otherwise. A select column takes Theme.targetHeight before the first column, which columnWidths leaves out of
what it shares: the header draws a tri-state CheckBox there (selectAll, named selectAllLabel) and each row a
CheckBox bound to selected (selectBox, named as its row). Each box's nextCheckState returns its current
state, so its look follows the selection alone; its clicked fires the row's tap with Ctrl, or the table's
selectAll, and a tap on a row's box is not also a tap on the row. A row is named by rowLabel, else its key. Selection is kept as the requested keys, marked on the
rows that have them, as the contract's "Selection by key" says; a user's change reports exactly the existing rows
selected.
A summary row (setRowSummary) is MorphTableRow.summary: a summaryFill rectangle in Theme.tableSummary
(color.table.summary) over its background, and its tap, context and long-press handlers off, so it is never
selected, activated or given a cell menu. A span across columns (RowSpan::columns) is a spanPlan entry's
columns: the spanning cell and its backdrop are laid out across that many columns from its own
(MorphTableRow.spanWidth), and the cells it covers in its row and the rows below are hidden.
Header bands (setBands) are the QML property bands, [{level, text, first, count, pinned}] with text the label
and its unit (ui::headerText): one item per run (band<index>), at its level's line above the group line, from the
left edge of the first column at the visible places it names to the right edge of its last, so a band moved apart is
two items and never covers a foreign column. groupRowHeight is everything above the column headers: the band lines,
then the group line.
A spanning cell (setRowSpans; TableImpl::planSpans resolves it against the rows as they stand, each time a row
comes, goes, moves or is told its spans) stays a cell of its origin row, left out of that row's tallest and
implicitHeight, and overflows the row downward: MorphTableRow.spanPlan ([{column, rows}], the spans clipped to the
rows that remain) names the cell, and the table gives the row spanBlocks ([{column, height}], the summed
implicitHeight of the rows the cell covers) and the last covered row a spanExtra, the lines the cell needs
beyond them, which that row's placeOnce adds; both are worked out at table level (recomputeSpans, once per event
loop turn, from the rows' ownHeight), as no row can see another's, and the cell's height never feeds back into a
row's own. The cell is not drawn in a layer of the table above the rows: it stays a child of its origin row, so its
focus, its accessible node and its key handling are the row's, and the row is drawn above every row below it (C++
writes z as the count of rows from it to the end), so the cell lies over the rows it covers, also when a covered row
is itself an origin in another column. Under the
cell, in its column, the row has a spanBackdrop: scheme.surface first, which hides the covered rows' rules, then a
second instance of the tableRow part's background component (a restyle is instantiated once more per spanning
cell), laid out as wide as the row and cut to the column so the row's own marks fall where they do on the row, and
given the origin row's tone, stripe, selected, hover and current state; its rule is thus the block's foot. The backdrop
has a TapHandler of its own, since a point below the origin row's bounds does not reach the row's handlers; its tap
is the origin row's tap (MorphTableRow.tapped), and a row ignores a tap that lands in a spanning or a covered column.
Hover is delivered only to an item whose bounds hold the pointer, so the row's containmentMask takes in the blocks of
its spanning cells beside its own rectangle: the row's HoverHandler is then hovered over any part of the cell, and
the covered row under the pointer is not, as the origin row is raised above it. A covered cell is hidden by ItemBase::cover, a flag kept apart from the
cell's own visibility (ownVisible() && !covered, so uncovering restores what the mount set and never shows a cell the
document hid): it takes no focus and no tap, has no accessible node, and is left out of widestCell and the column
caches as a hidden cell is. Accessible has no cell extent, so assistive technology reads the cell in its origin
row.
A table over a TableSource draws what the mount realizes (table.md, The renderer).
The mount gives it a horizontal-range handler before any row, and TableImpl::setOnHorizontalRange sets
sourceRows: the rows then go into a plain item (rowsPlane), not the column layout, and each is placed at the top
of its view row (setRowIndex writes viewRow), whatever its place among the children, since the focused row stays
realized outside the row window; a row is striped by its view row's parity, not its place. The measure.
tableMeasure answers pixels: a unit is Theme.unitWidth, a monospace character Theme.monoAdvance, a column's
padding table.cellPaddingX a side and a content column's start twelve units, so the mount gives a windowed fixed
column the width measure gives it unwindowed. Cells by column. setCellColumn writes the cell's measuredIndex (the column it
is placed in and reports its widths for) and pools a cell with none through ItemBase::cover, so a pooled cell is
hidden and placed nowhere; a row never places a source table's cells by their order, and places them once per event
loop turn however many a pass moves (schedulePlace). The column window.
setColumnWindow writes windowColumns ([{column, offset, width}], pixels, pinned first), windowTotalWidth and
pinnedShown, and sets arranged: from then on no width is worked out over every column (widths is empty and the
caches are not scanned), the header has a label for each window column only (headerCellCount), at its offset, and a
row places each cell at its column's offset and width. A pinned column's header label and cells are held at the
leading edge (x plus hflick.contentX), above the rest: a header label on the surface colour, and a row's pinned
cells over an opaque backdrop the row makes in cells for a table with pinned columns only (pinnedBackdrop: the
surface, then a further instance of the row's background cut to the pinned columns, so the row's state shows there
too), which the scrolled cells pass beneath. Only they follow a sideways scroll (placePinned). hflick reports its contentX and the viewport less the select column (hscroll), unless
setHorizontalOffset moved it; a cell reports its natural width and its least width (shrinkWidth within its natural width), each
plus the padding, the first time either is larger than what the column was told (measured), and the table reports
each header's width the same way, again when a font or a sort mark changes it; the mount grows a content column by them
and fits the stretch columns to the viewport (tableMeasure().shrinkFloor is 8 units). Row height. A row's measuredHeight is its tallest placed cell's plus the padding,
counted in rowMeasures, or the one-line height when every column keeps one line, which measures nothing.
layoutRows, once per event loop turn, sets each realized row's height to what it measures, but no lower than the
height it had when the column window (windowColumns: its columns or their widths, counted in windowEpoch) last
changed; a row measured again in the same window takes what it measures, so one measured while a pooled row still
held another row's cells settles to its own height (a row that left is forgotten), takes their mean as the height of every row not realized, places each row
at rowTop(viewRow), and moves flick.contentY so the first visible row keeps its place: a row above it that grows,
or a mean that changes, moves the view by as much (the mount holds no row heights, so this anchoring is
MorphTable's). The rows in view (rowAtY over the top and bottom of the viewport) are what the table reports.
Focus is the table's own: over a source, activeFocus stays on MorphTable, never on a row, which a recycled
slot would take away, and a tap gives it to the table; the arrows, Home, End, PageUp, PageDown, Ctrl+Home and Ctrl+End
fire focusMove with the FocusMove, Space and Enter act on the focused row when it is realized, and setFocusCell
writes focusedRowIndex and focusedColumnIndex, brings them into view (showFocusCell) and makes that row
current. A tap does not move the mount's focused cell: no seam carries a pointer's cell. Ranges. Shift with Up
or Down moves the focus and fires selectRange from the anchor (anchorRowIndex: the row last tapped or toggled, or
the one the focus left) to the focused row; a Shift-tap fires it to the tapped row; Ctrl+A and the select-all box
fire it over every row of the view, as Extend, unless the table has a setOnSelectAll handler
(selectAllHandled), when they fire selectAll instead, which TableImpl passes to the handler. TableImpl passes them to setOnSelectRange, which resolves them over rows not realized and
refuses one past maxRangeRows; each is multiple only. setSelectionView(except) marks every row but those keys until the
next setSelection; in that state a Ctrl-tap reports Extend with the keys now marked among the rows the table
holds, the tapped one toggled. setCounts writes
accessibleRowCount (-1 for a lower bound) and accessibleColumnCount; Accessible has no row or column count to
put them in, so they are properties only. Load states. setCellLoad writes the row's cellLoads; a cell not
loaded keeps its content bound at opacity 0 under a mark (loadMarks): a rounded bar 3 em wide for Unloaded, a
! of the same width for Failed, whose tooltip and accessible name say "Could not be loaded", each in the
column's alignment and neither measured into its width. Cell accents. setCellAccent writes the row's
cellAccents ({tone, tooltip, invalid} by column, the tone -1 for none); the row draws each accented cell's slot
(accentMarks, item cellAccent<column>): the tone's fill at half strength (cellTint, toneBgOf) over the row's
background and under the cells, so a cell keeps its tone in a toned or selected row and the selection fill and bar
show through it (a pinned cell's slot is the pinned backdrop's, over its copy of the background and under the pinned
cells, so it lies between the same layers); for a tooltip a small accent square at the slot's top end (moreMark), a ToolTip on
hover after the style's press-and-hold interval and at once while the cell holds the keyboard focus, and an
accessible ToolTip named by the text, ignored while there is none. An invalid cell draws the ! mark of a failed
load, with the accent's tooltip as its tooltip and accessible name. Cell marks and editors. setCellMarks
writes the row's cellMarks ({readOnly, modified, error, stale, muted} by column); the row draws each marked
cell's slot (cellMarkSlots, item cellMark<column>): a read-only cell's wash of the scheme's muted colour at 12%
(readOnlyWash), a modified cell's accent square at the slot's top start (modifiedMark), an error outline in the
scheme's error colour (errorOutline), and a stale or muted cell at the theme's muted opacity. setRowModified
writes the row's modified, an accent bar at the row's leading edge (rowModifiedMark). setCellEditor gives the
editor's item the cell's column (measuredIndex) and covers the cells of that column, so the row places the editor
over the cell's rectangle; null uncovers them, and gives the focus back to the table when the window's active
focus item was inside the closing editor; the row's editorColumn says which column it is, -1 for none, and
editorItem the editor's item: focus inside an open popup the editor owns (a control's popup, such as a combo
box's list, or a Popup among the data of the editor or a control inside it) counts as inside the table, though
the popup is drawn in the window's overlay; focus in any other popup or dialog is outside it. While a
table takes text (setOnText, MorphTable's takesText), printable text on the focused cell is its text event; a
table that takes cell clicks (reportsCellClicks) has each tap on a cell reported as its row's cellClick
({column, double}), the second tap of a double tap with double; and one that reports focus leaving
(reportsFocusOut) watches the window's active focus item and fires focusOut once it leaves the table and every
item in it. Headers with a unit. A column's unit is written after
its label, Mass [kg], the column is measured to that text, and the header's Accessible.name is
headerAccessibleName, Mass, kg. The status line (setStatus) is one Text under the
rows and outside the sideways scroll (statusText: the counts, the state, what stands and the message, two spaces
apart), with a "Retry" Button while the state offers it (retryShown), firing retry, and a Button for each of
its entries (statusEntries, {id, label}, the standing ones first; objectName statusEntry_<id>), firing
statusEntry with the id, which TableImpl passes to setOnStatusEntry; while not shown it takes no height. It is a
polite live region: once its text has held for half a second it is announced (Accessible.announce, from Qt 6.8,
polite by default), so a message is read out once and a count when it settles; before Qt 6.8 the text is the line's
accessible name (StaticText) and nothing is announced.
A heading row (setRowHeading, the row's heading) places its one cell from the first inset across the select
column and every column, less two insets; its TapHandler, Enter and select box are off, and shownRows (the rows the
current row, Ctrl+A and the select-all box run over) leaves it out, as does a content column's width scan. Its
background gets heading only when the part declares it, so a tableRow restyle that draws no headings still loads;
the stock MorphTableRowBackground fills a heading with scheme.tableHeader, as the header row is filled, which is
clear until a theme sets color.table.header, so in the stock theme a heading stands out by its content alone.
A column's header label (header<index>) is a Tab stop while it is sortable, or the table has menus or moves its
columns. A tap, Enter or Space on a sortable one fires sort with {column, shift}, shift while Shift is held
(HeaderClick::Shift; Ctrl, on a tap or a key, sorts as Plain), which reaches setOnSort; another header takes neither. The table never sorts: setSort writes
sortMarks and sortDescriptions, each by column, from ui::sortMarkText and ui::sortDescription, and a header in the
chain shows its mark after its text ( ▲, or ▲2 with two or more keys). Every sortable header keeps room for a
one-key mark in its column's floor, so the columns do not move when such a sort does, and for the mark it draws now,
so a header of a chain of two or more keys widens to hold its place ( ▲2) rather than cutting it. Qt's accessibility has no sort
state, so the header (a ColumnHeader named by its label, and {label}, filtered while filteredColumns names it)
states the order in its Accessible.description, sorted ascending or sorted ascending, key 2 of 3, and nothing out
of the chain.
Header menus. With menus (hasMenu), a right click on a header, or Shift+F10 or the menu key on a focused one, fires
menu with its column, and the ⋯ (tableMenuButton, named Table options) at the header's trailing end, held in view
over the sideways scroll, fires it with −1. The ⋯ has a width of its own (menuReserve, a touch target) that the
columns leave free, so it covers no header or filter button. C++ reads the entries then and calls
showMenu(column, entries), which opens configMenu, a Popup placed under that header (or the ⋯), at its start
where it fits. The popup takes the focus: Up and Down move among the entries that can be chosen, passing over
separators and headings, Right or Enter opens a submenu and Left or Backspace goes back up, Enter or Space chooses, and
Escape or a press outside closes it and gives the focus back to the header. An entry is drawn as a button-style
MorphMenu draws it (menuEntryText): a checkable entry's ✓ (or room for one), an icon the theme names drawn as its
icon (one it does not, written as its name), the label, › for a submenu, the chord after it, and the description as
a muted line under it; a separator is a MenuSeparator line. Each entry is an Accessible.MenuItem with its
description, and a checkable one is a checkable button whose checked follows its mark: the state is on the button, which is what assistive technology reads, and a click puts the binding back before it is acted on. A choice comes back as menuChoose with
the column and the path. A closed popup is not shown, so it is neither a Tab stop nor an
accessible node.
Cell menus. With a cell menu (hasCellMenu, from setCellMenu), a right click or a long press on a row's cell
(MorphTableRow.columnAt names the column under the pointer, a pinned column before the scrolled ones under it) fires
the row's cellMenu with the column, as Shift+F10 or the menu key does on the focused cell of a table over a source.
TableImpl::openCellMenu makes the row the selection alone, reported as Replace, when it is not marked, asks for the
entries, which focuses the cell, and calls showCellMenu(anchor, entries) with the cell's item: the same configMenu
opens under the cell, with the column −2, named Cell options for assistive technology, and the choice comes back as
menuChoose with that column, which C++ routes to the cell whose menu is open; closing it gives the focus back to the
table. Over a source, a key the table leaves is asked of C++ as cellKey: one that is none of the chords
setCellMenuKeys gave answers false at once, and one that is runs the focused cell's first enabled entry without a
submenu whose chord it is.
The column chooser and the sort dialog. "Columns…" and "Sort…" in the table's menu open dialogs the interpreter
builds from widgets the backend already has (ui/table_dialogs.hpp), so the backend adds nothing for them: each is a
MorphDialog (test ids table_columns and table_sort, titled Columns and Sort), mounted beside the table in a
column that takes the table's place, layout and visibility. The column has no gap, so the dialogs' zero-sized
placeholders add no space. Inside it the table fills the column across, and along it unless its height is fixed or a
stretch: a row offers to fill its height to the column, and a share of the row is the column's to take. The chooser holds,
per column in the layout's order, a MorphCheckbox and two MorphButtons (Move up, Move down), then Reset columns, Group columns… with its form (a MorphTextInput, a check box per column, Create group), a line and a
Remove group button per user-formed group, and Done; the sort dialog, per key, two MorphSelects (the column, and
ascending or descending) and Move up, Move down and Remove, then Add key and Done. Escape or a press
outside dismisses either, which closes it as Done does. Each change applies as it is made; a refusal goes to the
table's status line, under the dialog.
The filter menu. A filter button, "Filter…" and a group's "Filter {group}, {k} columns…" open a third dialog the
interpreter builds from the same widgets (ui/table_filter_menu.hpp): a MorphDialog (test id table_filter, titled
with the column's or the group's label) beside the other two. A values list is a MorphTextInput search, a
MorphCheckbox per value ({text} ({count}), (Select all), (Blanks)), a muted MorphText heading per dimension
of a Measure column, a ▸ MorphButton on a date bucket that opens, and More values; a muted note says the list
may grow, how many cells could not be read, or why Apply applied nothing. The conditions are MorphSelects (the
condition, and or or, a Measure column's unit, a group's match line) and MorphTextInputs, a date column's
operand a MorphDateTimeInput; an operand that does not read draws its field's error. Apply and Clear filter
end it. Escape or a press outside closes it; a condition waiting for its debounce is dropped with it. The backend adds
nothing for it.
Moving and resizing. While the table moves its columns (movable), dragging a header and releasing it over
another fires columnMove with the dragged column and the other's visible place (visibleColumns, or the column's own
index when every column shows), and Ctrl+Shift+Left and Ctrl+Shift+Right on a focused header fire it with the place one
over. While it resizes them (resizable), each header ends in a MorphTableHeaderEdge (edge<index>, six pixels, a
split cursor): dragging it fires columnResize with the header's new width in pixels, from which C++ takes the cell
padding on both sides (measurePadding, which the mount adds back) and rounds the rest to units of Theme.unitWidth,
and a double click on it fires the column with no width. A tap on the edge does not also sort. A sort tap reads Shift
from its handler's point, which carries the modifiers.
Filters and groups. A filterable column's header ends in a filter ToolButton (filter<index>), ▿, or ▾ while
filteredColumns names the column, which fires filter. With columnGroups, a row groupRowHeight tall sits above
the headers: each group's label spans the headers at the visible places it names, worked out from the widths and the
column window the header is laid out by (columnBox), so it follows order, hidden and pinned columns, widths and the
sideways scroll; it ends in its own filter button (groupFilter<index>), filled while the group is filtered, which
fires groupFilter. A filterable header keeps room for its button in its column's floor, and is named
{label}, filtered only while it is filterable and filtered. Ctrl+C on the table or a focused header, while the table
copies (copies), fires copy.
The clipboard is QGuiApplication::clipboard(): copyText sets its text.
A row draws its background part (background, the tableRow part restyle) under its cells and hands it its state:
selected, hovered (the pointer over the row), current (keyboard focus within the row), alternate (an odd
position, which C++ writes on every row after each append, destroy and move), tone (setRowTone: −1 for none,
else the ui::Tone index), selectColumn (whether the table's select column shows the selection) and its scheme.
setRowMarks writes the row's own busy, locked, unmatched and marksTooltip: an unmatched row draws at
Theme.mutedOpacity, a busy one shows busyMark (a 3 px bar in Theme.tableBusy just inside the selection's bar,
anchored so that it follows a right-to-left layout), a locked one lockedWash (a Theme.tableLocked wash over its
cells), and a non-empty marksTooltip is the row's tooltipText; without one a locked row says "Locked by another
user" and a busy one "Saving this row", over the row's own tooltip.
The row's height is the larger of its cells' and the background's implicitHeight; the stock background draws
three marks that compose, then the hairline between rows, and its implicit height is a dense row's,
Theme.targetHeight - 8. A toned row is tinted (tint: the tone's bg colour at half strength over scheme.surface)
and draws no bar. A selected row has the accent's 3 px bar at its leading edge (selectionBar) and, unless the table
has a select column, whose box already shows the state, the selection colour as its fill (fill) over the tint. The
select column's boxes, the row's and the select-all box over the table, draw their indicator with
MorphCheckIndicator, which MorphCheckbox draws as well: a rounded square outlined in scheme.controlBorder
while unchecked, filled with the accent and marked with a check while checked, and marked with a dash while the
select-all box is partly checked.
The header row draws its own background part (headerBackground, the tableHeader part restyle) behind the column
labels, and hands it only scheme: the header has no selection, hover, focus or tone of its own. The stock
background fills with scheme.tableHeader (color.table.header, transparent by default) and draws a 1 px rule
(headerRule) over its last pixel row in scheme.tableHeaderRule (color.table.headerRule, transparent by default),
so a table draws no header fill and no rule until a theme sets them. The rule lies inside the header's height, so no
row moves. A document-authored column's role (a TextRole) styles its default cell's
text and has no effect on a column with its own cell.
Virtualized tables. A table whose row count has crossed its Virtualization::threshold
(docs/superpowers/specs/2026-10-22-table-row-virtualization-design.md) realizes a widget only for
rows the mount's windowing Effect decides are in or near the visible range; MorphTable.qml owns its
own Flickable, with leading and trailing spacer items standing in for the rows not realized, sized
by an estimate (estimatedRowHeight) that corrects itself toward the real average height of whichever
rows are actually realized. A document-authored table must therefore have an explicit height
(Fixed or Stretch sizing) once it is large enough to virtualize — unlike every other table, which
grows to its content's full height and relies on an ancestor to scroll it.
Two consequences follow directly from only some rows ever being realized:
- Column widths become monotonic, not exact. The width cache (above) can only answer "how wide is the widest realized cell," not the widest cell in the whole table; without a rule for that, a content column's cached width would shrink back down whenever the row that set its current maximum scrolls out of the realized range, then grow again if a wider row scrolls back in — jitter on every scroll, not a one-time correction. A virtualized table's column widths therefore only ever grow: a column may stay wider than currently necessary once the row that justified it has scrolled away, in exchange for never visibly narrowing and widening as the user scrolls.
- Selection survives a row leaving the realized range.
existingSelection()'s ordinary check — is this requested key a currently-realized row's key — would otherwise drop a selected key the moment its row scrolls out of view, since nothing short of the row's ownTableRowImplnormally proves a key still exists. A virtualized table additionally tracks every key the mount reports as existing in the data at all (TableWidget::setExistingKeys), realized or not, and a requested key already in that set is never dropped from the reported selection just because it has no realized row right now.
A ui::Key crosses into QML as text — i:<int64> or s:<text> — and back through decodeKey, never as a JavaScript
number, so an id above 2^53 is exact: a drag key, a table row's key, and an option's identity (QML sees only the
option's index and label; the keys stay in C++).
Chords are matched in C++: QML hands the key and the modifiers of a key press to the widget's relay, and the
first declared chord they press runs. A chord is modifiers (Ctrl, Shift, Alt, Meta) joined to a key name by
+: a letter or a digit, F1 to F24, or Enter (either Return key), Esc or Escape, Tab, Up, Down,
Left, Right, Space, Delete. Letters match without regard to case; the modifiers must be exactly those
pressed. A key press propagates from the focused item outwards, so the innermost widget declaring the chord takes
it; a widget out of reach takes none.
SpotlightImpl (MorphSpotlight.qml) draws a tour's spotlight over the window's content item at z 10000, not as a
popup: a popup's item takes every press inside it, and a press inside the cut-out must reach the target. It takes no
room in its parent's layout.
- Target. It reads its own context's
WidgetIndexand rings the first widget carrying the test id whose item is visible (QQuickItem::isVisible, which is false inside a hidden container or an unselected tab page). It hears the index and each candidate'svisibleChanged. - Drawing. Four
Theme.scrimrectangles around the cut-out, which is exactly the target's box, dim everything else, the ring's band included, so a press there reaches the scrim; a ring inTheme.focus,Theme.spaceOf(1)outside the target's box, surrounds it. The layer shows while the spotlight is open and its item is visible. The card is aTheme.cardSchemerectangle, at most 40 units wide, on the side of the target with the most room, clamped a step 2 gap inside the window; with no target it is centred and nothing is cut out. - Geometry. Each frame (
QQuickWindow::afterAnimating) it reads the target's scene box, so it follows resizes, layout passes and scrolling. A closed spotlight tracks nothing. A target clipped by the nearest flickable (aScrollWidget) is scrolled into view once, when it becomes the ringed target (or the spotlight opens), never on later frames, so the person can scroll away; a box taller or wider than the viewport shows its top or left edge. - Pointer. The scrim and the card's own area take presses; the cut-out has no item, so a press there reaches the target.
- Keys. While open it filters the window's key presses. Tab and Shift+Tab always cycle through the card's tab
stops, then the target's focus item while
setTargetFocusable(true), wherever focus is, so the trap survives a card button that hides. Enter and Space belong to the focused control. Every other key goes to the card's widgets (MorphWidget.takeChord) whatever has focus, the target included: the focused widget and its ancestors in the card first, then the rest of the card, then the spotlight's own chords; so the card's chords come before a card control's own keys. Focus outside the card is on the target or on a popup it opened: the key is offered to that item and its ancestors first, and only a key none of them accepted reaches the card's chords, so Escape closes an open menu before it ends the tour. A button-style menu's popup takes focus when it opens (focus: true), which is what lets it receive Escape. A card widget withouttakeChordis logged at error. Opening focuses the card's first tab stop; closing hands focus back to the item that had it.
A MorphWidget's sizing maps to QtQuick.Layouts: content to the implicit size, fixed(n) to a preferred size of
n units, stretch(w) to fill with stretch factor w, percent(n) (widthKind 3) to a preferred width of n percent of the width inside the padding of the MorphStack two levels up from the child (the stack, its layout, the child: MorphWidget.shareWidth reads that stack's width and insetX, never the layout between them, whose width in a row packed at its natural length is its own implicit width, which includes the share), with no fill and no stretch factor, so a percent child is placed as a fixed one: a stack's or a panel's content minimum still raises it, a table, a scroll or a leaf takes its own overflow. While a shown child of a row is a percent, MorphStack.implicitWidth is the sum of naturalLengths (a percent child counted at its natural width) plus the gaps and the padding, never layout.implicitWidth, which sums the shares and would follow the width a parent derives from it; shownLengths, which counts the share, feeds betweenSpacing. A percent select draws at its implicit width, as a fixed one does; a percent dialog, drawer, grid track or table column is refused before it gets here. The bounds map to Layout.minimumWidth, maximumWidth,
minimumHeight and maximumHeight of n units (MorphWidget's minWidthUnits, maxWidthUnits,
minHeightUnits, maxHeightUnits; −1 for none, which resets the layout's default): QtQuick.Layouts shares the
length a capped item leaves among the others, and places a fill item its maximum stops at the start. showLayout
writes a bound given and offers an absent one, so a component that declares no bounds is reported only for a node
that has one. A unit is the body font's average character width
horizontally and its line height vertically (Theme.unitWidth, Theme.unitHeight): the platform font's, or the
theme's font.family at the body size once a theme names one (../ui/theme.md, "On Qt Quick").
Along its axis a MorphStack without wrap shares its length among the children that stretch (stretch sizing, or a
MorphSpacer, which counts as weight 1: its expandsByDefault) by weight, from zero, with the bounds resolved as
the contract says. stretchShares is the binding that does it: an array aligned with the layout's children, -1 for a
child that does not stretch, built from the length inside the padding, the other children's lengths, gapLength and
each stretching child's weight and Layout.minimum*/maximum*, never from a stretching child's preferred length;
Shares.shareByWeight (MorphShares.js) is the pass loop. A stretching child's Layout.preferredWidth (stretchWidth) or preferredHeight
(stretchHeight) is its share (shareOf of the layout it is in, duck-typed as roomOf is: MorphStack.shareOf, or the content column of a container, below), so the GridLayout places the shares
exactly. The stack's own implicit length along the axis is naturalLength while a child stretches: the other
children's lengths, the gaps and W * max(n / w) for the stretching ones (naturalAlong, with Shares.stretchNatural), which never reads a share,
since the shares follow the length a parent derives from the natural. widthFreeNatural along a row is the same
function over each child's widthFreeNatural where it has one, else its implicitWidth, so a stretch row in a content
sized context, a table cell or a panel still asks for its children's naturals. The containers that hold their children
in a column (panel, collapsible, scroll, slot, tab page, dialog and drawer) hold them in a MorphShareColumn, a
ColumnLayout that applies the same rule down: a stretch-height child (or a spacer) takes a share of the column's
height by weight from zero (stretchShares, shareOf), and naturalHeight is the others' heights, the spacing and
Shares.stretchNatural of the stretching ones. A container reads naturalHeight, never the column's implicitHeight,
which sums the shares and follows the height the column is given: a scroll's, a dialog's and a drawer's content
column is naturalHeight tall (the scroll's contentHeight, and the dialog's and drawer's ScrollView contentHeight, follow it), a slot's is the viewport's height less its inset where a child stretches (never less than the children's minHeight) and naturalHeight otherwise, and a
panel's, a collapsible's and a tabs node's pages column asks its parent for naturalHeight as its preferred height (MorphTabs.implicitHeight reads pages.naturalHeight). A push button (style 0) is not narrowed below its natural width
(contentMinimumWidth), as a badge is; a list item, a select, an input and a menu trigger have no minimum.
Unbreakable segments. Qt's line breaker is not reachable from QML, so the backend writes a TextMeasure
(src/qt_quick/text_measure.hpp) as Theme.textMeasure when it starts, and takes it back when it goes. Its
widestSegment(pieces) walks QTextBoundaryFinder (the Unicode line-break analysis Qt's own wrapping uses) over the
pieces' joined text, each piece a {text, font} map (a run and its drawn face), and measures each segment, between two
line-break opportunities and without the whitespace that ends it, as the sum of QFontMetricsF advances of the
parts each piece holds. While the property is null (before the backend has written it) a text and a key-value keep
no minimum. Text.Wrap stays the last resort where a container cannot give a segment its room, and the container then
reports its overflow on morph.layout as for a badge. A banner's message, a dialog's description and a toast's label are
sized by their own kinds, and a fixed width has no minimum: the GridLayout shrinks a fixed neighbour.
A content-sized dimension fills the container across its axis (../ui/backend_contract.md,
the cross axis). A QML child cannot see its parent's axis, so the container says: ContainerCore::adopt writes the
child's fillsWidth and fillsHeight from crossFill(), which is the width for every container but a row (the
height), a splitter and a table row (neither, since they size their own children). MorphWidget binds
Layout.fillWidth to a stretch width, or a content width with fillsWidth, and the same for height. Along its axis a
MorphStack whose shown children do not stretch keeps its layout at its natural length, so the children pack at the
start: a GridLayout given more length hands the spare to the gaps between its cells.
A container's minimum is its content's. MorphWidget gains contentMinimumWidth (−1 for none) and
honoursContentMinimum, and Layout.minimumWidth is the document's minWidth, else contentMinimumWidth while
honoursContentMinimum, else −1. A MorphStack binds it to twice its horizontal padding plus its layout's own
Layout.minimumWidth (for a wrapping row, its widest child's minimum, since a wrapping row can be as narrow as that; a child's minimum is the lesser of its basis and its shrinkWidth, which a text that wraps sets to its widest word, a stack to its content's, and every rigid widget leaves at −1 for its natural width); a
MorphPanel to its padding, its border and its inner column's Layout.minimumWidth. A MorphTabs, a table, a scroll,
a slot and every leaf keep −1: a slot is a page that takes its own overflow, so tabs have nothing to add. A
QtQuick.Layouts layout never gives an item less than its minimum, so a row of content-sized children that cannot fit
raises its column's minimum and so on up to a container whose width its parent does not choose (a window's root, a
page, a splitter pane), where the content is wider than the container. TableRowImpl offers each of its cells
honoursContentMinimum: false: a table places a cell at its column's width, and a cell whose minimum rose past it would
push its row out of line with the header.
The overflow report. A stack compares its content's minimum (layout.Layout.minimumWidth, for a wrapping row the
widest child's basis) with the width inside its padding (width - 2 * insetX, not layout.width: a packed row lays
its layout out at its implicit width, which is always its minimum); a panel compares inner.Layout.minimumWidth with
inner.width; a slot and a vertical scroll compare their column's; a table compares its columns' width with its own.
Content wider by 2 px or more overflows. The splitter checks nothing: its panes are plain widgets, and each pane's stack
checks itself. MorphWidget.checkOverflow runs after the layout settles (Qt.callLater) when the width, the
overflow or the visibility changes or the widget gets a window, and only while the container is visible, wider than 0 and
in a window, so start-up, a hidden tab page, a folded section and a closed overlay report nothing. It reports once per
container while it is mounted (overflowReported); a later width, another overflow or the same one again reports
nothing, so nothing grows with the widths seen. The report is the relay event overflow that ContainerItemWidget
hears, written as a warning of the morph.layout category (reportOverflow), so an application filters it with
QT_LOGGING_RULES and every render smoke records it with its other Qt warnings. It names the container by its test id,
else by its kind and the nearest ancestor that has one, then the need and the room, then the child whose minimum alone
exceeds the room when there is one: column `page` needs 512 px and has 430 px: `footer` and its siblings neither wrap nor shrink. A table says table `conditions` scrolls sideways: its columns need 612 px and it has 490 px.
Alignment. ContainerCore::adopt also offers each child alignAcross (1 for a column's child, placed
horizontally; 2 for a row's or a grid's, placed vertically; 0 elsewhere) and crossAlign, the container's
ui::Align index; setAlign re-offers crossAlign to every child already held (alignChildren), since a child is
adopted in its constructor, before its container can be aligned. showLayout writes a node's alignSelf (−1 for
none, offered) and its bleed (offered when false). A MorphStack that was told headBar (setHeadBar) has the gap Theme.headPaddingY in place of Theme.spaceOf(gap) while that token is above 0, so it is exactly the space above and below the line of the shell's expanded head bar, and any value is honoured, a smaller one included. A bleeding MorphWidget takes Layout.leftMargin and Layout.rightMargin of minus its parent's childBleedInset, which each container's content item carries: a MorphStack's layout its horizontal padding, a MorphPanel's content column its padding (the frame's inner edge, not its border), and a MorphTabs' pages their page padding. A MorphStack that is a holder (passesBleed, written by StackImpl::setPassesBleed) adds the childBleedInset of its own parent to its own, so a bleeding child of a panel's or a tab page's several children reaches the same edges as a lone one; a layout draws outside its bounds, so nothing forwards the child's width. A layout honours the negative margins, so the node's implicit width adds nothing to the container's. MorphWidget places itself by alignSelf, else crossAlign: under start, centre or end it sets
Layout.alignment (AlignLeft, AlignHCenter, AlignRight in a column; AlignTop, AlignVCenter, AlignBottom
in a row or grid) and drops the cross fill of a content-sized dimension, while a stretch one keeps its fill and its
maximum places it. Along the axis, while no shown child stretches, MorphStack sizes its layout to its natural length
and offsets it by justify: none, half the spare length or all of it. For between the layout keeps the full length
and its spacing is max(gap, spare / (shown − 1)), the spare computed from each shown child's preferred (else
implicit) length clamped into its Layout minimum and maximum, because a GridLayout given more length gives it to
its cells, not its gaps. Its implicit length along the axis is then those lengths and the gaps, not the layout's:
the layout's includes the spacing taken from the stack's length, which a parent that sizes the stack from its
implicit length would feed back, widening the stack on every pass.
Surfaces. Theme.scheme(name) is the colour scheme of a surface (MorphScheme: the colour roles, each the
theme's unless the surface sets it), and the theme itself for the empty name. Every MorphWidget draws with
scheme: its own surface's when it has one, else inheritedScheme, which its container writes when it adopts it
(ContainerCore::scheme(); the roots give the theme). The mount sets a node's surface before it mounts the node's
children, so a container's scheme is known when they are adopted. A widget with a surface draws its background under
its content. applyTheme(engine, values, surfaces) sets every role of each named surface's scheme in place, so a
widget that holds one follows a later theme.
The roots fill the window as one column: a root whose height stretches takes what the others leave, as on the terminal; without one, the roots keep their own heights at the top.
A spacing step (a stack's or grid's gap, a panel's padding) is Theme.spaceOf(step) px, from the space.0 …
space.5 tokens, not a number of units. A stale field is dimmed; a
field's errors show under it in the error colour; a required field is marked. The Theme singleton holds the colour
roles every component reads, with the ui-theme/1 defaults; applyTheme(engine, values) sets them from a theme's
tokens, and a host component that imports MorphUi reads the same instance (../ui/theme.md).
The controls are Qt Quick Controls' Basic ones, drawn from the theme rather than with that style's look: an input
(MorphInputBackground) and a button (MorphButtonBackground) are Theme.targetHeight tall (controlHeight, or
at least touchHeight while the window is compact, ../ui/theme.md) with
Theme.radiusControl corners and a border that takes the focus colour; a read-only input (readOnly, which every
input passes its background) draws on Theme.background rather than its scheme's surface; a check box's indicator is accent-filled when
checked; a tab bar underlines the current tab in the accent; a progress bar is the scheme's accent on its neutral track,
Theme.spaceOf(1) tall with rounded ends, and an indeterminate one a third-wide accent segment sliding across it while
shown; a key-value's captions keep their whole width on one line, and its values fill what is left and wrap in it; a table's header is muted and its rows dense with a
hairline between them; a panel is a card; a heading is Theme.headingPixels, bold; and the window behind every
surface is Theme.background.
Components holds the QML a client renders beside the built-in kinds (spec 5 §10):
-
Bundle components (
addBundle(name, qml, digest)) load only when the text's SHA-256 is the digest the bundle names (sha256:<hex>), and compile in a contained engine whose root context holds nothing, from aqrc:base URL in a directory no resource has, so a relative import finds nothing. -
Host components (
addHost(name, version, url)) are QML the client carries; they load into the backend's own engine, so they may import the application's other modules, at the version a document asks for or later. -
The restyle map (
restyle(engine, kind, component)) names a component for a built-in kind or part. The component must declare every property and function of itsMorphUibase — one that extends it does — and one that does not is refused when it is mapped, naming what it lacks; the kind then keeps itsMorphUicomponent. A base's properties are its restyle API, so a property a base gains is one a restyle written from scratch must then declare. There are two kinds of restyle:- A kind restyle replaces a kind's whole component. A text input's restyle (
textInput) replaces its single-line component, and atextArearestyle its multi-line one (MorphTextArea, whose API isMorphField's field API withplaceholder,edited,assigningandassign(value)). - A part restyle replaces one drawn part inside a component C++ creates, never its layout. The container's
component declares the part as a
Componentproperty, and C++ passes the context's component for the part's type, restyled or not, as an initial property when it makes the container.
Restyle kind MorphUibaseWhat it replaces Base API (beyond its Qt type's) tableRowMorphTableRowBackgrounda table row's background: selection, hover, focus, zebra, tone, and the row's minimum height selected,hovered,current,alternate,tone(−1 none, else aui::Toneindex),schemetableHeaderMorphTableHeaderBackgrounda table's header row background schemescrollBarMorphScrollBar(aScrollBar)the bar a scroll area attaches on its axis schemesplitterHandleMorphSplitterHandlethe handle between two panes of a splitter axis,scheme; the handle readsSplitHandle.pressedand.hoveredA
scrollBarrestyle is aScrollBarsubclass: the names checked are every one beyondQQuickItem's, so the base's include all ofScrollBar's. The layout kinds (column, row, grid, spacer, scroll, slot, splitter, drop zone) are not restyled as kinds; what a scroll area and a splitter draw of their own is restyled as their parts, and the refusal says so (`scroll` is a layout kind; restyle its bar as `scrollBar`). - A kind restyle replaces a kind's whole component. A text input's restyle (
-
Backend::createCustom(parent, {name, props, minVersion})loads a component and checks that it declares every prop the document declares. A component reports its events throughhost.fire(event, payload)(hostavarproperty it declares and the backend sets);CustomWidget::setOnEventreceives the event's name and the payload as text, a JavaScript array or object as JSON. A prop is set as text (string,int,exact,json), abool, or adouble(number, the one kind of value that crosses as a double). -
A component that is not registered, does not match its digest, does not compile, is a host component below the version asked for, or lacks a declared prop makes
createCustomreturn null, and the caller shows the fallback. Each failure is reported once per component and reason, through the callback andfailures().
createCustom is ui::IViewBackend::createCustom, and CustomWidget and CustomRequest are the view tree's own
types: Mounted asks for a document's custom node here first, binds its props, and shows the fallback only on null.
tests/qt_quick/, registered under MORPH_BUILD_QT_QUICK with the ctest label qt_quick, run offscreen with the
software scene graph:
- Conformance. Every case of
ui::testing::conformanceCases()passes on the real engine through a probe that sends mouse presses, moves, releases and key events to the window at a widget's place (a menu entry and a file drop go through the component's own entry point, which its items and its drop area call). A probe that delivers no input, or misreads every text, fails the cases that check them. - The backend's own cases, for what the probe cannot reach: read-only fields of every kind, widgets out of reach, chords, dates in a zone, table placement and selection modes, overlays dismissed by Escape and by a press outside, moves that keep the item, split views, scroll areas, drop zones.
- Documents on the real engine: a bound property follows its value; a flush is one frame and a later flush another; a refused selection snaps back; typing keeps the cursor; a dialog dismisses and reopens; a list change moves the fewest rows and keeps the kept rows' items and focus; a table row keyed above 2^53 is reported exactly; spec 5 §7's server-calculated values show in their rows, stale and never blank while a newer request is in flight, with the row's error on a failure.
- Several mounts: two backends on two items of one window over one engine, one
Componentswith atextInputrestyle and one session: both pages' inputs are the restyle, a mutation on one page refreshes a query the other shows, each host's diagnostics hold only its screen's, and destroying the first page leaves the second's input editable; a restyle mapped after the first page made its input reaches only the second. - Components: props and events; a digest mismatch, a compile error, a missing component, an old host component
and a missing prop each leave the fallback, reported once; a restyle that lacks the kind's API is refused; a
tableRowrestyle draws every row's background, sets the row's height, and seesalternatefollow a move and a destroy; atextArearestyle is what a multi-line input is made of, and one withoutassignis refused; ascrollBarrestyle is the bar a scroll area attaches, and one that is noScrollBaris refused; asplitterHandlerestyle is every handle, and a 12 px one makes the panes leave 12 px where the stock one leaves 6;scrollandsplitteras kinds are refused naming their part kinds; a write of a property the item does not declare is refused and reported once, and a custom component in a container is offered no placement it does not declare. - Automation conformance: a generated screen read back through
QAccessiblefrom the window's interface, as a driver reads it, with the accessibility machinery switched on: the document's names and roles, a button's role, name and press action, a key-value pair named"<caption>: <value>", the test id asobjectNameand, from Qt 6.8, as the accessible identifier, and every input kind as one node found by its name and role, the same node as its test id, that a driver focuses and types into (a text input) or sets (a slider), with a radio select's options as radio buttons. - The column window (
test_qt_quick_table.cpp,QuickWindowFixture: a table overFakeRowsin a 1,280 × 800 window, every column 64 px): the cells and header cells alive are the windows' (F2); flings create no cell once the pools are warm (F8); the focused cell survives a scroll of 10,000 rows and 200 columns, with the view's counts (F10); hiding and moving a column create no cell items (D8); the status line shows the counts and "Retry"; an unloaded cell draws its placeholder and a failed one its mark, neither widening the column; a row's height does not shrink when the column window moves and is forgotten when the row leaves the row window, and a table of one-line columns measures none; a row growing above the view keeps the rows in view where they are; a windowed fixed column is as wide as an unwindowed one; a tap keeps the focus on the table and the status line is announced (from Qt 6.8); Shift with an arrow, Ctrl+A and the select-all box select through the mount. - qmllint over every
MorphUicomponent, through the module's lint target, failing on any warning (tests/qt_quick/run_qmllint.cmake).
A page is an Item of its displayed size holding an inner Item of the sheet's pixel size, 96 device-independent
pixels to 25.4 mm on both axes whatever the screen's DPI, with scale set from ui::layoutPage and
transformOrigin: Item.TopLeft; regions are children of the inner item in node order, positioned from the layout's
rectangles. The page asks its layout for Layout.fillWidth: true, Layout.minimumWidth: 0, Layout.maximumWidth the sheet's
width and implicitHeight the displayed height. It draws on the paper surface; its role is QAccessible::Document, and a
region is exposed to assistive technology only when named. A region clips its content, and a clipped one draws a fade
with … over its last line. See ui/document_page.md.
| Decision | Why |
|---|---|
An IViewBackend, not a QML generator |
The interpreter mounts only through Mounted, numbers slots per instance, and builds rows, cases and dialog content per instance from closures; a static per-screen QML document cannot hold them. Implementing the backend contract holds this renderer to the same conformance suite as every other. |
| One component per kind, compiled once | QQmlComponent caches the compiled type; each widget is one create. |
| C++ writes the control's own state, not a property it binds | A binding is not re-evaluated when its source has not changed, so a refused edit could not snap back through it. |
| Keys stay in C++ | A JavaScript number loses integers above 2^53; QML never needs a key, only a label and an index, or the key's text. |
| Handlers released when the widget is destroyed, the item deleted later | QML may be inside the item's handler; the handlers must not keep the screen's scopes alive. |
| Restyle checked by declared names | A restyle component that extends the MorphUi one passes by construction; one written from scratch must offer everything the backend writes and calls. |
- The WebAssembly build, its smoke executable and the browser history (spec 3 §10), which come separately.
- A runtime density from theme tokens; the units come from the body font, not the scale tokens.
- A per-template QML generator in place of per-kind components, which needs the interpreter to lower without mounting and to number slots per template.