狀態與資訊
SplashScreen 啟動畫面
應用程式啟動期間覆蓋內容區域,顯示圖示與載入進度,就緒後即可關閉。
範例
屬性預覽載入失敗。請再次點選屬性預覽重試。

用法
應用程式啟動
預設為 Branded 品牌啟動樣式,Simple 為置中載入圓環;載入完成後可呼叫 dismiss() 關閉。
#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
可重複使用的啟動覆蓋層,覆蓋其父控制項並顯示圖示與載入進度,僅在覆蓋區域內阻擋輸入;dismiss() 會將其隱藏並發出 dismissed(),而不會刪除自身。
建構函式
解構函式
列舉
enum class PresentationBranded 為預設的柔光顯影效果;Simple 則保留置中的載入圓環。
BrandedSimple
方法
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 退場時圖示飛入的目標控制項;在 Full 動態模式下,若目標於同一視窗內可見則平滑飛入,否則淡出。
void setProgress(int done, int total)設定確定進度(限制於 0–100%);total <= 0 時切換為不確定模式。達到 100% 不會自動關閉;啟動完成後請呼叫 dismiss()。
void dismiss()執行退場轉場動畫後隱藏啟動畫面,並發出一次 dismissed();若已隱藏或正在退場則忽略,之後可再次呼叫 show() 重複使用。
屬性
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 replaced()當另一個重疊的 SplashScreen 取代並隱藏此執行個體時發出。不會發出 dismissed();直接呼叫 hide() 或視窗最小化也不會發出 replaced()。
受保護成員
方法
繼承自 fluent::FluentElement
列舉
enum Theme解析設計 token 時使用的全域視覺佈景主題。
Light = 0Dark = 1HighContrast = 2
方法
static void setTheme(Theme theme)更新全域主題,並通知使用中的 FluentElement 執行個體。
static void setThemeDeferred(Theme theme)排程以可見元素優先的批次主題重新整理,避免阻斷目前的互動。
static Theme currentTheme()傳回目前生效的全域主題。
static bool themeUsesDarkAppearance(Theme theme)傳回主題是否使用深色底的視窗框架與材質 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()在全域主題變更後呼叫。
型別與別名
struct Colors傳回給元件使用的設計 token 快照。
繼承自 fluent::QMLPlus
方法
AnchorLayout::Anchors* anchors()傳回 QWidget 宿主的可變錨點。
void setState(const QString& name)依名稱套用已註冊的狀態,或在 @p name 為空時還原為預設狀態。未知名稱會被忽略,離開該狀態後原有的繫結會恢復同步。
void addState(const QMLState& state)註冊或取代具名狀態定義;若取代目前啟用中的狀態則會立即套用。
void evaluateStates()依註冊順序重新評估狀態條件並啟用第一個符合的狀態,若無符合項目則恢復為預設狀態。相依屬性發出通知時也會自動執行;使用 extend 的衍生狀態會繼承上層變更,除非發生循環或缺失。
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)透過 PropertyBinder::bind() 將 @p source 上的 @p sourceProp 繫結至此 QWidget 宿主上的 @p targetProp。
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)設定透過 writeProperty() 或繫結寫入 @p propertyName 時使用的預設動畫。明確的 StateTransition 規則優先;直接呼叫 C++ setter 不會有動畫。
void clearBehavior(const char* propertyName)移除後續受管理寫入所使用的預設動畫。
bool writeProperty(const char* propertyName, const QVariant& value)透過 Behavior 寫入宿主屬性,且不移除該屬性的繫結。
Qt 基底類別文件:QWidget