基础能力
字体与排版
用字体角色区分标题、正文和说明文字。
字体角色
Typography 有 9 种角色:Caption(12px)、Body(14px)、BodyStrong(14px 加粗)、BodyLarge(18px)、BodyLargeStrong(18px 加粗)、Subtitle(20px)、Title(28px)、TitleLarge(40px)和 Display(68px)。在 Label 上用 setFluentTypography() 设置角色。
#include <FluentQt/TextFields.h>
auto* title = new fluent::textfields::Label("Account settings", this);
title->setFluentTypography(Typography::FontRole::Subtitle);import fluentqt
title = fluentqt.Label("Account settings")
title.setFluentTypography(fluentqt.FontRole.Subtitle)为其他控件设置字体
不是 Label 的控件,可以在 C++ 中用 Typography::fontStyle(role).toQFont(),在 Python 中用 fluentqt.font_for_role(role) 获取 QFont。对 Fluent 控件调用 setFont() 后,它可能不再随主题字体变化,具体见该控件的 API。
#include <FluentQt/Design.h>
customWidget->setFont(Typography::fontStyle(Typography::FontRole::BodyStrong).toQFont());import fluentqt
custom_widget.setFont(fluentqt.font_for_role(fluentqt.FontRole.BodyStrong))