Qt ui design

From Mte90/dotfiles · View interactive version

Qt ui design is an AI agent skill from the GitHub repository Mte90/dotfiles. Design or audit UI for Qt/QML, Qt projects, web, or embedded MPU or MCU targets. Use when creating screens, layouts, navigation, or auditing UX.

How to use this skill

Skill file

Qt UI Design

Before producing UI output, confirm you know: target platform, screen geometry, design system, content priority, viewing distance, locale, and input methods. Run the seven items below as a check against the conversation and the project state; ask only the items that are genuinely missing. When the user cannot answer an item, choose a sensible Qt default and name it in your response so the user can correct it.

Small edits to an existing design — for example "move the OK button to the right", "change this label", "make this red" — do not trigger the checklist. Apply section 1 silently and verify section 2 (contrast, hit-target) where relevant.

0. Context check (before designing)

Use the seven items below to decide what is already known and what to ask. If the conversation or repository has already answered an item, do not re-ask.

  1. Target platform — Desktop, web browser, mobile, or specific hardware (MCU, Raspberry Pi, other embedded board)?
  1. Screen shape — Rectangle (default), Square, or Circle?
  2. Resolution and DPI — Do you know the screen resolution and DPI? (Approximate is fine.)
  3. Design system — Check whether the project already uses a design system or Qt Quick Controls style. If so, follow it and reuse its tokens. If not, recommend a Qt Quick Controls style: Basic, Fusion, Imagine, Material, Universal, iOS, or FluentWinUI3 (the iOS and FluentWinUI3 styles require Qt 6.7 or later). Where the project follows a third-party design language (Material Design 3, Apple Human Interface Guidelines, Fluent 2), map its tokens to the corresponding Qt Quick Controls style rather than introducing a parallel token vocabulary.
  4. Content priority — What information is most important (primary), secondary, and tertiary on this screen?
  5. Viewing distance — How far will users be from the screen? (e.g. handheld ~30 cm, desk ~60 cm, panel ~1.5 m, wall ~3 m)
  6. Locale and input — What is the primary locale/language? Is RTL (Arabic, Hebrew, Farsi, Urdu) support required? What input methods must be supported (touch, keyboard, mouse/pointer, hardware buttons, voice)?

If the target is an embedded or MCU device, also read section 4 in full before any design decisions — it overrides several desktop defaults.

If the user is requesting an audit of an existing design, skip to section 5 (Audit).


1. Design principles to apply (all targets)

Apply these while designing. Do not ask about each one — use them to inform decisions silently.

Content and layout:

Perception and interaction:

Reading patterns (use to guide information placement):

Buttons and CTAs:

Error prevention:

Responsiveness (desktop/web only — embedded: see section 4):

1.1 Motion and animation (desktop/web — embedded: see section 4)

Motion communicates state, relationship, and causality. Every animation must be functional, not decorative.

1.2 Typography scale (desktop/web)

For embedded typography, see section 4.4. This subsection governs desktop and web targets only.

Use a modular scale to derive all type sizes. A modular scale is a sequence of numbers related by a fixed ratio — every size is mathematically proportional to every other, producing a scale that feels harmonious rather than arbitrary. The ratios are listed below; see also https://www.modularscale.com/ for an interactive generator.

How to build the scale
  1. Choose a base — the size at which your body text looks best at the target viewing distance. For desktop at ~60 cm, 16 px is a reliable starting point. The base is your ms(0).
  2. Choose a ratio — multiply the base by this ratio to get the next step up, divide to get the next step down. Pick based on the character of the product:

| Ratio | Name | Factor | Character |

|---|---|---|---|

| 8:9 | Major second | 1.125 | Compact, dense — good for data-heavy UIs, installer flows |

| 5:6 | Minor third | 1.200 | Moderate — good for general desktop apps |

| 4:5 | Major third | 1.250 | Open, comfortable — good for marketing, onboarding |

| 3:4 | Perfect fourth | 1.333 | Strong contrast — good for dashboards, bold hierarchy |

| 1:1.618 | Golden section | 1.618 | High contrast — use sparingly; large gaps between steps |

  1. Map scale steps to roles — assign a step number to each typographic role. Never add roles not on the scale; if a size is needed, pick the nearest step.
Worked example (base 16 px, Perfect Fourth 1.333)

| ms() | Value (px, rounded) | Role |

|---|---|---|

| ms(3) | 37.9 → 38 px | Display / hero text |

| ms(2) | 28.4 → 28 px | Page title / H1 |

| ms(1) | 21.3 → 21 px | Section heading / H2 |

| ms(0) | 16 px | Body — base |

| ms(-1) | 12.0 → 12 px | Caption / label / metadata |

Use a maximum of three to four of these steps per screen. More than four active sizes creates visual noise.

Rules that apply to all modular scales
Qt/QML implementation

In QML, define the scale as a singleton (e.g. TypeScale.qml) so sizes are referenced by role name, not hardcoded values:

// TypeScale.qml — generated from modular scale, base 16, ratio 1.333
pragma Singleton
import QtQuick

QtObject {
    readonly property real base:    16   // ms(0)
    readonly property real h2:      21   // ms(1)
    readonly property real h1:      28   // ms(2)
    readonly property real display: 38   // ms(3)
    readonly property real caption: 12   // ms(-1)
}

Reference via TypeScale.h1 in components. Recalculate the whole singleton when the base or ratio changes — never patch individual values.

Register the singleton in your QML module so it can be imported. In a qmldir file:

module MyApp.Theme
singleton TypeScale 1.0 TypeScale.qml

In CMake with qt_add_qml_module:

qt_add_qml_module(myapp_theme
    URI MyApp.Theme
    VERSION 1.0
    QML_FILES TypeScale.qml
)
set_source_files_properties(TypeScale.qml PROPERTIES QT_QML_SINGLETON_TYPE TRUE)

1.3 Multi-input and keyboard navigation (desktop/web)

Every desktop and web interface must support multiple input methods. Do not design for pointer alone.

1.4 Semantic colour

Colour should communicate meaning consistently across the entire interface. Avoid arbitrary colour choices.

1.5 Localisation and RTL layout

Ask question 7 in the intake. Act on the answer here.


2. Accessibility (WCAG 2.2)

Check every design against these before delivering:


3. AI-specific UX

When designing screens that involve AI features:


4. Embedded and MCU targets

This section overrides desktop defaults. Read it fully before designing for any embedded, MCU, or hardware-constrained target.

Hardware facts that drive every decision (collect these during the intake step above if not already answered):

4.1 Rendering without a GPU

Software rasterisation means every visual effect costs CPU time.

| Allowed | Not allowed |

|---|---|

| Flat solid fills | Gradients |

| 1 px solid strokes | Drop shadows |

| Bitmap (PNG) icons and fonts | Blur or transparency layers |

| Opacity-only transitions | Simultaneous move + fade animations |

| Fixed pixel layout | Flexbox or fluid layout |

Prefer bitmap icons over vector paths — raster cost is paid at compile time, not runtime. Relax these constraints only when a GPU is confirmed.

Exceptions. The constraints above apply to runtime software rasterisation. Qt Quick Ultralite supports compile-time-baked gradients via its static rendering pipeline. Some MCUs ship with a 2D blitter or a small GPU that relaxes the no-blur and no-transparency constraints. Verify the hardware data sheet and the Qt toolchain in use before treating the table as a hard prohibition.

4.2 Layout

4.3 Interaction

4.4 Typography

Embedded fonts are bitmaps — size is fixed at build time. Get it right from the start.

| Viewing distance | Minimum size |

|---|---|

| ~50 cm (handheld, appliance) | 14 px min, 16 px preferred |

| ~1.0–1.5 m (HMI, instrument cluster) | 20 px min |

| ~2–3 m (wall panel, public display) | 28 px min |

Contrast ≥ 4.5:1 for all text. Embedded screens often have poor viewing angles and bright ambient light — higher contrast is always better.

4.5 Error and safety

4.6 Desktop → MCU quick reference

| Rule | Desktop / web | MCU / embedded |

|---|---|---|

| Responsiveness | Flexbox, fluid | Fixed pixel layout |

| Animation | Easing curves, ≤ 400 ms | Opacity-only, < 200 ms |

| Progressive disclosure | Tooltips, hover | Explicit button only |

| Touch targets | 44 px recommended | 48 px default (relax only with explicit safety review) |

| Font rendering | Vector, OS-scalable | Bitmap, fixed at build time |

| Status communication | Color + token-based | Color + shape + text |

| Error recovery | Undo | Confirm before action |

| State visibility | Status bar / tooltip | Always on screen |

| Navigation depth | Unlimited | Max 2 levels |

| Localisation | QLocale, RTL mirroring | QLocale only (RTL rarely applicable) |


5. Audit instructions

When auditing an existing design, categorize every finding:

  1. Critical — Violates a core UX law or WCAG accessibility rule. Must fix.
  2. Warning — Potential friction or elevated cognitive load. Should fix.
  3. Opportunity — Enhancement or AI-driven improvement. Consider.

Apply section 4 constraints first if the target is embedded.

Extended audit checklist for desktop/web targets:


6. References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.