Skip to content

MetaUI widgets take their colours from QPalette — hosts must populate it, or they paint with the platform palette #18

Description

@barrulus

Informational — no action needed in Meta unless you want the design changed. Recording it because
it cost a while to spot, and any future host will hit exactly the same thing.

What happens

Every custom-painted MetaUI widget sources its colours from QPalette:

  • slider_float.cpp, slider_int.cppBase, Text, Highlight, HighlightedText, Mid
  • range_bar.cpp, curve_canvas.cpp, points_canvas.cpp, xy_canvas.cpp, vector_canvas.cpp,
    gradient_picker.cpp — same roles

That is the right Qt idiom, but it means the host has to put its theme into the palette. A host
that themes itself with a stylesheet — which is the common case, and what Hesiod does — does
not thereby populate the palette: a stylesheet color: rule only reaches widgets Qt draws
itself, never a paintEvent() that calls palette().color(...).

The result is silent and easy to misread as a styling bug in Meta: the widgets fall back to the
platform palette. On Hesiod/Windows that was near-black Text on a #2B2B2B background —
labels and values almost invisible — and Highlight resolving to the Windows system accent
instead of the application's, so fill bars and handles were the wrong blue.

Worth noting the predecessor did this differently: QSliderX exposed an explicit colour channel
(qsx::Config::global.color_text, color_bg, color_border, …) that the host pushed values into.
Migrating to MetaUI removes that channel, and nothing fails loudly when a host forgets to replace
it with palette setup.

Fix on the host side

Hesiod resolved it in otto-link/Hesiod@c175920d by building a QPalette from the same colour set
its stylesheet placeholders use and calling app.setPalette(pal) before setStyleSheet(...).
Widgets Qt draws itself are unaffected — the stylesheet still wins for those.

Image

Possible follow-ups in Meta, your call

  1. Document it — a line in the MetaUI readme saying widgets read QPalette and hosts must
    populate it, which is probably enough.
  2. Provide a helper — e.g. meta::qt::apply_theme(QApplication&, const ThemeColors&) so hosts
    have an obvious entry point rather than having to know which palette roles matter.
  3. Leave as-is — palette is the idiomatic Qt answer; this issue then just serves as the
    searchable record of the failure mode.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    theme: attributes-widgetsMeta widgets, sliders, brush/array editors, theming/palette

    Type

    No type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions