Fluent-Qt

導覽

NavigationView 導覽檢視

提供調適型左側窗格與內容區域的頂層導覽框架。

範例

NavigationView 導覽檢視: 外框插槽

用法

外框插槽

頁首、主區與頁尾外框皆為呼叫端擁有的控制項;NavigationView 僅負責配置其外殼幾何位置。

#include <FluentQt/Navigation.h>
using namespace fluent::navigation;

auto* navView = new NavigationView(this);
navView->setMinimumWidth(440);
navView->setMaximumWidth(620);
navView->setFixedHeight(340);
navView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
navView->setDisplayMode(NavigationView::DisplayMode::Left);
navView->setExpandedPaneWidth(180);
navView->setHeaderChromeWidget(headerSection);
navView->setMainChromeWidget(mainSection);
navView->setFooterChromeWidget(footerSection);
populateNavigationPages(navView->contentHost());
auto routeToPage = [host = navView->contentHost()](int pageIndex) {
    const int direction = pageIndex >= host->currentIndex() ? 1 : -1;
    host->setCurrentIndex(pageIndex, direction, true);
};
headerSection->onActivated = routeToPage;
mainSection->onActivated = routeToPage;
footerSection->onActivated = routeToPage;

fluent::navigation::NavigationView

繼承自 QWidget · FluentElement · QMLPlus

自適應導覽外殼控制項,管理窗格幾何版面、頂部/側邊切換過渡、緊湊寬度與響應式斷點;導覽窗格控制項與頁面內容由呼叫端提供。

建構函式

解構函式

列舉

enum class DisplayMode
  • Auto
  • Left
  • LeftCompact
  • LeftMinimal
  • Top

方法

DisplayMode displayMode() const

套用回應式約束前所請求的導覽版面配置模式。

void setDisplayMode(DisplayMode mode)

套用回應式約束前所請求的導覽版面配置模式。

DisplayMode effectiveDisplayMode() const

套用回應式條件約束後的顯示模式。

bool isPaneOpen() const

導覽窗格是否開啟。

void setPaneOpen(bool open)

導覽窗格是否開啟。

int compactModeThresholdWidth() const

進入精簡導覽模式的寬度閾值。

void setCompactModeThresholdWidth(int width)

進入精簡導覽模式的寬度閾值。

int expandedModeThresholdWidth() const

進入展開導覽模式的寬度閾值。

void setExpandedModeThresholdWidth(int width)

進入展開導覽模式的寬度閾值。

int expandedPaneWidth() const

展開模式下的導覽窗格寬度。

void setExpandedPaneWidth(int width)

展開模式下的導覽窗格寬度。

int compactPaneWidth() const

精簡模式下的導覽窗格寬度。

void setCompactPaneWidth(int width)

精簡模式下的導覽窗格寬度。

int topBarHeight() const

頂部導覽列高度,單位為像素。

void setTopBarHeight(int height)

頂部導覽列高度,單位為像素。

bool isAnimationEnabled() const

窗格與版面配置模式切換時是否播放轉場動畫。

void setAnimationEnabled(bool enabled)

窗格與版面配置模式切換時是否播放轉場動畫。

bool setHeaderChromeWidget(QWidget* widget, WidgetOwnership ownership)

以明確的所有權原則設定頁首窗格控制項。

QWidget* takeHeaderChromeWidget()

卸離並傳回頁首外框控制項,不套用其擁有權清理動作。

bool releaseHeaderChromeWidget()

移除頁首外框控制項,並依其設定的所有權原則處理。

bool setMainChromeWidget(QWidget* widget, WidgetOwnership ownership)

以明確的所有權原則設定主窗格控制項。

QWidget* takeMainChromeWidget()

卸離並傳回主外框控制項,不套用其擁有權清理動作。

bool releaseMainChromeWidget()

移除主體外框控制項,並依其設定的所有權原則處理。

屬性

DisplayMode displayMode

套用回應式約束前所請求的導覽版面配置模式。

讀取 displayMode()設定 setDisplayMode()變更訊號 displayModeChanged()
DisplayMode effectiveDisplayMode

套用回應式條件約束後的顯示模式。

讀取 effectiveDisplayMode()變更訊號 effectiveDisplayModeChanged()
bool paneOpen

導覽窗格是否開啟。

讀取 isPaneOpen()設定 setPaneOpen()變更訊號 paneOpenChanged()
int compactModeThresholdWidth

進入精簡導覽模式的寬度閾值。

讀取 compactModeThresholdWidth()設定 setCompactModeThresholdWidth()變更訊號 compactModeThresholdWidthChanged()
int expandedModeThresholdWidth

進入展開導覽模式的寬度閾值。

讀取 expandedModeThresholdWidth()設定 setExpandedModeThresholdWidth()變更訊號 expandedModeThresholdWidthChanged()
int expandedPaneWidth

展開模式下的導覽窗格寬度。

讀取 expandedPaneWidth()設定 setExpandedPaneWidth()變更訊號 expandedPaneWidthChanged()
int compactPaneWidth

精簡模式下的導覽窗格寬度。

讀取 compactPaneWidth()設定 setCompactPaneWidth()變更訊號 compactPaneWidthChanged()
int topBarHeight

頂部導覽列高度,單位為像素。

讀取 topBarHeight()設定 setTopBarHeight()變更訊號 topBarHeightChanged()
bool animationEnabled

窗格與版面配置模式切換時是否播放轉場動畫。

讀取 isAnimationEnabled()設定 setAnimationEnabled()變更訊號 animationEnabledChanged()
qreal layoutTransitionProgress

導覽版面配置轉場使用的進度。

讀取 layoutTransitionProgress()設定 setLayoutTransitionProgress()

訊號

void displayModeChanged(DisplayMode mode)

套用回應式約束前所請求的導覽版面配置模式。

void effectiveDisplayModeChanged(DisplayMode mode)

套用回應式條件約束後的顯示模式。

void paneOpenChanged(bool open)

導覽窗格是否開啟。

void compactModeThresholdWidthChanged(int width)

進入精簡導覽模式的寬度閾值。

void expandedModeThresholdWidthChanged(int width)

進入展開導覽模式的寬度閾值。

void expandedPaneWidthChanged(int width)

展開模式下的導覽窗格寬度。

void compactPaneWidthChanged(int width)

精簡模式下的導覽窗格寬度。

void topBarHeightChanged(int height)

頂部導覽列高度,單位為像素。

void animationEnabledChanged(bool enabled)

窗格與版面配置模式切換時是否播放轉場動畫。

PySide6 擴充

受保護成員

方法

繼承自 fluent::FluentElement

列舉

enum Theme

解析設計 token 時使用的全域視覺佈景主題。

  • Light = 0
  • Dark = 1
  • HighContrast = 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。

void addTransition(const StateTransition& transition)

依優先順序註冊狀態轉場。

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