状态与信息
SplashScreen 启动屏幕
应用启动时覆盖内容区,显示加载进度。
示例

用法
应用启动
Branded 是默认样式,Simple 只显示居中的加载圆环;示例可以重放结束时的过渡。
#include <FluentQt/StatusInfo.h>
using namespace fluent::status_info;
auto* root = new QWidget(this);
auto* layout = new QVBoxLayout(root);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(12);
const QIcon appIcon(":/app/assets/app-icon.png");
auto* host = new fluent::layout::Card(root);
host->setObjectName("splashPreviewHost");
host->setAppearance(fluent::layout::Card::Canvas);
host->setBorderVisible(false);
host->setFixedHeight(400);
auto* contentLayout = new QVBoxLayout(host);
contentLayout->setContentsMargins(24, 24, 24, 24);
auto* header = new QHBoxLayout;
auto* logo = new Label(host);
logo->setObjectName("splashDestinationIcon");
logo->setFixedSize(28, 28);
header->addWidget(logo);
header->addWidget(new Label("FluentQt Gallery", host));
contentLayout->addLayout(header);
contentLayout->addStretch();
auto* splash = new SplashScreen(host);
splash->setObjectName("sampleSplash");
splash->setIcon(appIcon);
splash->setTitle("FluentQt");
splash->setSubtitle("Small details. Fluent experiences.");
splash->setText("Starting FluentQt Gallery");
splash->setTransitionTarget(logo);
QObject::connect(splash, &SplashScreen::dismissed, logo,
[logo, appIcon]() { logo->setPixmap(appIcon.pixmap(28, 28)); });
splash->show();
// Demo timing only; applications report actual work and call dismiss when ready.
auto* loading = new QVariantAnimation(splash);
loading->setObjectName("sampleSplashLoading");
loading->setDuration(3600);
loading->setStartValue(0);
loading->setEndValue(120);
QObject::connect(loading, &QVariantAnimation::valueChanged, splash, [splash](const QVariant& value) {
const int step = value.toInt();
splash->setProgress(qMax(0, step - 20), 100);
splash->setIndeterminate(step < 20);
splash->setText(step < 100 ? "Loading resources" : "Opening Gallery");
});
QObject::connect(loading, &QVariantAnimation::finished, splash, &SplashScreen::dismiss);
auto restart = [splash, loading, logo]() {
loading->stop();
splash->hide();
logo->clear();
splash->setIndeterminate(true);
splash->show();
loading->start();
};
auto* presentation = new fluent::basicinput::ComboBox(root);
presentation->setObjectName("splashPresentation");
presentation->setAccessibleName("Splash presentation");
presentation->addItems({"Branded", "Simple"});
QObject::connect(presentation, QOverload<int>::of(&QComboBox::currentIndexChanged), splash,
[splash, restart](int index) {
splash->setPresentation(index == 0 ? SplashScreen::Presentation::Branded
: SplashScreen::Presentation::Simple);
restart();
});
auto* replay = new Button("Replay startup", root);
replay->setObjectName("replaySplashButton");
replay->setFluentStyle(Button::ButtonStyle::Accent);
QObject::connect(replay, &Button::clicked, splash, restart);
auto* controls = new QHBoxLayout;
controls->addWidget(presentation);
controls->addStretch();
controls->addWidget(replay);
layout->addWidget(host);
layout->addLayout(controls);import fluentqt
from PySide6.QtCore import QVariantAnimation
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout
from importlib.resources import files
# Gallery-only preview drawing/model helpers are omitted.
root = SplashScreenSampleSurface()
layout = QVBoxLayout(root)
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(12)
app_icon = QIcon(str(files("fluentqt_gallery") / "assets" / "app-icon.png"))
host = fluentqt.Card(root)
host.setObjectName("splashPreviewHost")
host.setAppearance(fluentqt.Card.Appearance.Canvas)
host.setBorderVisible(False)
host.setFixedHeight(400)
content_layout = QVBoxLayout(host)
content_layout.setContentsMargins(24, 24, 24, 24)
header = QHBoxLayout()
logo = fluentqt.Label(host)
logo.setObjectName("splashDestinationIcon")
logo.setFixedSize(28, 28)
header.addWidget(logo)
header.addWidget(fluentqt.Label("FluentQt Gallery", host))
content_layout.addLayout(header)
content_layout.addStretch()
splash = fluentqt.SplashScreen(host)
splash.setObjectName("sampleSplash")
splash.setIcon(app_icon)
splash.setTitle("FluentQt")
splash.setSubtitle("Small details. Fluent experiences.")
splash.setText("Starting FluentQt Gallery")
splash.setTransitionTarget(logo)
splash.dismissed.connect(lambda: logo.setPixmap(app_icon.pixmap(28, 28)))
splash.show()
# Demo timing only; applications report actual work and call dismiss when ready.
loading = QVariantAnimation(splash)
loading.setObjectName("sampleSplashLoading")
loading.setDuration(3600)
loading.setStartValue(0)
loading.setEndValue(120)
def update_progress(value):
splash.setProgress(max(0, int(value) - 20), 100)
splash.setIndeterminate(value < 20)
splash.setText("Loading resources" if value < 100 else "Opening Gallery")
loading.valueChanged.connect(update_progress)
loading.finished.connect(splash.dismiss)
def replay_startup():
loading.stop()
splash.hide()
logo.clear()
splash.setIndeterminate(True)
splash.show()
loading.start()
presentation = fluentqt.ComboBox(root)
presentation.setObjectName("splashPresentation")
presentation.setAccessibleName("Splash presentation")
presentation.addItems(["Branded", "Simple"])
def change_presentation(index):
mode = fluentqt.SplashScreen.Presentation
splash.setPresentation(mode(index))
replay_startup()
presentation.currentIndexChanged.connect(change_presentation)
replay = fluentqt.Button("Replay startup", root)
replay.setObjectName("replaySplashButton")
replay.setFluentStyle(fluentqt.Button.ButtonStyle.Accent)
replay.clicked.connect(replay_startup)
controls = QHBoxLayout()
controls.addWidget(presentation)
controls.addStretch()
controls.addWidget(replay)
layout.addWidget(host)
layout.addLayout(controls)API
查看声明没有匹配的 API 成员。
fluent::status_info::SplashScreen
继承自 QWidget · FluentElement · QMLPlus
可重复使用的启动遮罩,覆盖父控件内容区。
构造函数
属性
Presentation presentation- 读取
presentation()设置setPresentation()通知presentationChanged() QIcon icon- 读取
icon()设置setIcon()通知iconChanged() QSize iconSize- 读取
iconSize()设置setIconSize()通知iconSizeChanged() QString text- 读取
text()设置setText()通知textChanged() QString title- 读取
title()设置setTitle()通知titleChanged() QString subtitle- 读取
subtitle()设置setSubtitle()通知subtitleChanged() QWidget* transitionTarget- 读取
transitionTarget()设置setTransitionTarget()通知transitionTargetChanged() int progress- 读取
progress()通知progressChanged() bool indeterminate- 读取
isIndeterminate()设置setIndeterminate()通知indeterminateChanged()
方法
void setPresentation(Presentation presentation)选择启动效果,不改变进度或所有权;未知枚举值忽略。
void setIconSize(const QSize& size)设置图标首选尺寸,每个维度至少为一个逻辑像素;空间不足时按比例缩小。
void setText(const QString& text)设置纯文本状态;长文本显示省略,辅助功能仍能读取完整内容。
void setTitle(const QString& title)设置 Branded 效果中可选的纯文本品牌标题。
void setSubtitle(const QString& subtitle)设置品牌标题下可选的纯文本副标题。
void setTransitionTarget(QWidget* target)借用图标容器作为 Branded 退场的目标。
void setProgress(int done, int total)设置确定进度并限制在 0–100%;total <= 0 切换为不确定模式。
void dismiss()退场并隐藏后发送一次 dismissed;重复调用或已隐藏时不做任何操作。
信号
void replaced()被重叠宿主上的新遮罩替换并隐藏后发送;不发送 dismissed,也不自动销毁。
枚举
enum class PresentationBranded 默认使用柔光显影;Simple 保留居中加载环的简洁效果。
BrandedSimple
析构函数
子类扩展接口
方法
继承自 fluent::FluentElement
方法
static void setTheme(Theme theme)更新全局主题,并通知所有活跃的 FluentElement 实例。
static void setThemeDeferred(Theme theme)以可见元素优先的批次调度主题刷新,避免阻塞当前交互。
static Theme currentTheme()返回当前生效的全局主题。
static bool themeUsesDarkAppearance(Theme theme)返回指定主题是否使用暗色底的 chrome 与材质 token。
static void refreshTheme()在设计 token 变化后重新广播当前主题以触发重绘。
static int themeGeneration()每次主题变化自增的单调计数器,用于过期判断。
Theme effectiveTheme() const解析此元素实际使用的主题,会优先读取 QWidget 父链上的局部主题覆盖。
bool effectiveThemeUsesDarkAppearance() const返回此元素的实际主题是否使用暗色底 chrome。
bool setThemeOverrides(const QJsonObject& overrides)供组件侧访问的设计 token 接口。
QJsonObject themeOverrides() const返回当前元素的覆盖配置。
void clearThemeOverrides()恢复全部 token 跟随全局主题。
const Colors& themeColorsRef() const对当前色板的零拷贝访问(用于绘制热路径)。
Material::AcrylicToken themeAcrylic() const材质、阴影和自适应布局 token。
QColor themeBackdrop(bool active) const给定激活状态下的窗口 chrome 背景色。
virtual void onThemeUpdated()全局主题变化后调用。
枚举
enum Theme解析设计 token 时使用的全局视觉主题。
Light = 0Dark = 1HighContrast = 2
类型与别名
struct Colors返回给组件使用的设计 token 快照。
继承自 fluent::QMLPlus
方法
AnchorLayout::Anchors* anchors()返回 QWidget 宿主的可变锚点配置。
void setState(const QString& name)应用具名 state;名称为空时恢复默认状态。
void addState(const QMLState& state)注册或替换一个具名 state 定义。
void evaluateStates()重新计算条件;按注册顺序选择首个成立的条件。
QMLPlusRuntime* runtime()返回按需创建、由宿主持有的状态观察对象。
void setAnchors(const AnchorLayout::Anchors& anchors)替换宿主的全部锚点,并使父布局失效。
void resetAnchors()清除宿主全部锚点,并使父布局失效。
void bind(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction dir = PropertyBinder::OneWay)将 source 属性绑定到 QWidget 宿主上的 target 属性。
BindingHandle bindManaged(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction direction = PropertyBinder::OneWay, BindingOptions options = {})在当前 QWidget 宿主上安装可管理的直接绑定。
BindingHandle bindComputed(const char* targetProp, const QVector<BindingDependency>& dependencies, std::function<QVariant()> evaluate, BindingOptions options = {})在当前 QWidget 宿主上安装使用显式依赖的 C++ 表达式绑定。
void setBehavior(const char* propertyName, const PropertyAnimation& animation)设置宿主受管理属性写入时使用的默认动画。
void clearBehavior(const char* propertyName)移除后续受管理写入使用的默认动画。
bool writeProperty(const char* propertyName, const QVariant& value)通过 Behavior 写入宿主属性,且不移除该属性的绑定。
Qt 基类完整成员:QWidget