Fluent-Qt

Foundations

Themes and colors

Switch the application theme and read theme colors for custom painting.

Switch the theme

FluentElement::setTheme() switches the application between Light, Dark, and HighContrast, and existing Fluent controls repaint. To change tokens on one element only, pass a JSON object to setThemeOverrides(). Overrides survive theme changes and do not apply to child widgets.

#include <FluentQt/Foundation.h>

fluent::FluentElement::setTheme(fluent::FluentElement::Dark);

Use theme colors

Read colors by role, such as textPrimary or bgCanvas, instead of hard-coding RGB values, so custom painting follows the theme. In C++ paint code, use themeColorsRef(); in Python, subclass fluentqt.FluentWidget and use theme_tokens().

#include <FluentQt/Foundation.h>

// Inside a FluentElement-based widget's paintEvent()
const auto& colors = themeColorsRef();
const QColor background = colors.bgCanvas;
const QColor text = colors.textPrimary;

API reference