集合檢視
TreeView 樹狀檢視
瀏覽、展開與選取樹狀階層資料的控制項。
範例
屬性預覽載入失敗。請再次點選屬性預覽重試。

用法
資料夾階層
用 setModel() 繫結樹狀模型。內建預設列支援展開/收合、鍵盤導覽與選取狀態,也可透過自訂 delegate 繪製更豐富的列樣式。欄標題預設隱藏;呼叫 setHeaderHidden(false) 可顯示模型的水平標題資料,並使用 header() 設定欄寬與標題列行為。setHeaderText() 會在欄標題上方新增獨立標題。使用外置標題列時,請隱藏欄標題並將標題留空,把外層版面配置間距設為 0,再呼叫 setHeaderlessTopInset(0) 移除第一列上方預設的 2 個邏輯像素。
#include <FluentQt/Collections.h>
using namespace fluent::collections;
auto* tree = new TreeView(this);
tree->setItemDelegate(new TreeRowDelegate(
themeHost, rowHeight, tree, tree));
tree->setModel(model);
tree->setAccessibleName("Folders");
tree->expandAll();import fluentqt
tree = fluentqt.TreeView()
tree.setAccessibleName('Folders')
tree.setItemDelegate(row_delegate)
tree.setModel(model)
tree.expandAll()API
檢視宣告沒有符合的 API 成員。
fluent::collections::TreeView
繼承自 QTreeView · FluentElement · QMLPlus
具備階層選取指示器動態效果與核取狀態同步的樹狀檢視。基於 QTreeView 建置,支援展開/收合動畫、移動選取膠囊、標題/預留文字及拖曳重排。
建構函式
解構函式
列舉
enum class IndicatorVerticalDirectionNoneUpDown
enum class IndicatorHierarchyTransitionNoneSameLevelInwardOutward
方法
SelectionMode selectionMode() const集合檢視使用的選取模式。
void setSelectionMode(SelectionMode mode)集合檢視使用的選取模式。
Typography::FontRole fontRole() const用於文字繪製的 Fluent 排版角色。
void setFontRole(Typography::FontRole role)用於文字繪製的 Fluent 排版角色。
bool borderVisible() const是否繪製控制項外框邊線。
void setBorderVisible(bool visible)是否繪製控制項外框邊線。
bool backgroundVisible() const是否繪製控制項背景。
void setBackgroundVisible(bool visible)是否繪製控制項背景。
QString headerText() const欄標頭與資料列上方的可選標題。欄標頭預設隱藏;可使用 setHeaderHidden(false) 顯示模型標頭資料。
void setHeaderText(const QString& text)欄標頭與資料列上方的可選標題。欄標頭預設隱藏;可使用 setHeaderHidden(false) 顯示模型標頭資料。
int headerlessTopInset() const標題與欄標頭皆隱藏時首列上方的間距,預設為 2 個邏輯像素。設為 0 可緊貼外部標頭邊緣。
void setHeaderlessTopInset(int inset)標題與欄標頭皆隱藏時首列上方的間距,預設為 2 個邏輯像素。設為 0 可緊貼外部標頭邊緣。
QString placeholderText() const模型沒有項目時顯示的預留文字。
void setPlaceholderText(const QString& text)模型沒有項目時顯示的預留文字。
bool viewportHovered() const檢視區目前是否處於懸停狀態。
bool canReorderItems() const是否啟用拖曳重新排序。
void setCanReorderItems(bool enabled)是否啟用拖曳重新排序。
bool isScrollChainingEnabled() const邊界處的滾輪輸入是否可繼續傳遞至外層捲動容器。
void setScrollChainingEnabled(bool enabled)邊界處的滾輪輸入是否可繼續傳遞至外層捲動容器。
bool isOverscrollEnabled() const在捲動邊界是否啟用彈性回彈效果。預設為啟用;若希望捲動於邊緣俐落停止則可停用。
void setOverscrollEnabled(bool enabled)在捲動邊界是否啟用彈性回彈效果。預設為啟用;若希望捲動於邊緣俐落停止則可停用。
qreal indicatorMotionProgress() const樹狀結構選取指示器的動畫進度。
IndicatorVerticalDirection indicatorMotionDirection() const樹狀指示器動態效果使用的垂直方向。
IndicatorHierarchyTransition indicatorHierarchyTransition() const樹狀指示器動態效果使用的階層轉場模式。
bool isIndicatorMotionAnimationEnabled() const是否啟用樹狀指示器動態動畫。
void setIndicatorMotionAnimationEnabled(bool enabled)是否啟用樹狀指示器動態動畫。
QRectF selectedIndicatorRect() const傳回目前選取指示器在視口座標中的幾何區域。
QRectF selectedIndicatorRect(qreal progress) const傳回指定正規化轉場進度下的選取指示器幾何區域。
SelectionIndicatorStyle selectionIndicatorStyle() const傳回選取指示器覆蓋層所使用的樣式。
bool selectionIndicatorVisible() constFluent accent 選取指示器覆蓋層是否可見。
qreal selectionIndicatorHeight() const傳回 Fluent 選取指示器膠囊的高度。
void setSelectionIndicatorHeight(qreal height)設定 Fluent 選取指示器膠囊的高度。
bool isHorizontalFluentScrollBarEnabled() const傳回是否可顯示 Fluent 水平捲軸覆蓋層。
void setHorizontalFluentScrollBarEnabled(bool enabled)啟用或停用 Fluent 水平捲動軸覆蓋層。
qreal chevronRotation(const QModelIndex& index) const傳回供委派繪製使用的展開箭頭旋轉進度(0 = 收合,1 = 展開)。
屬性
SelectionMode selectionMode集合檢視使用的選取模式。
讀取selectionMode()設定setSelectionMode()變更訊號selectionModeChanged()Typography::FontRole fontRole用於文字繪製的 Fluent 排版角色。
讀取fontRole()設定setFontRole()變更訊號fontRoleChanged()bool viewportHovered檢視區目前是否處於懸停狀態。
讀取viewportHovered()變更訊號viewportHoveredChanged()qreal indicatorMotionProgress樹狀結構選取指示器的動畫進度。
讀取indicatorMotionProgress()變更訊號indicatorMotionProgressChanged()IndicatorVerticalDirection indicatorMotionDirection樹狀指示器動態效果使用的垂直方向。
讀取indicatorMotionDirection()變更訊號indicatorMotionDirectionChanged()IndicatorHierarchyTransition indicatorHierarchyTransition樹狀指示器動態效果使用的階層轉場模式。
讀取indicatorHierarchyTransition()變更訊號indicatorHierarchyTransitionChanged()bool indicatorMotionAnimationEnabled是否啟用樹狀指示器動態動畫。
讀取isIndicatorMotionAnimationEnabled()設定setIndicatorMotionAnimationEnabled()變更訊號indicatorMotionAnimationEnabledChanged()bool horizontalFluentScrollBarEnabled控制是否允許顯示 Fluent 水平捲軸覆蓋層。
讀取isHorizontalFluentScrollBarEnabled()設定setHorizontalFluentScrollBarEnabled()bool borderVisible是否繪製控制項外框邊線。
讀取borderVisible()設定setBorderVisible()變更訊號borderVisibleChanged()bool backgroundVisible是否繪製控制項背景。
讀取backgroundVisible()設定setBackgroundVisible()變更訊號backgroundVisibleChanged()QString headerText欄標頭與資料列上方的可選標題。欄標頭預設隱藏;可使用 setHeaderHidden(false) 顯示模型標頭資料。
讀取headerText()設定setHeaderText()變更訊號headerTextChanged()int headerlessTopInset標題與欄標頭皆隱藏時首列上方的間距,預設為 2 個邏輯像素。設為 0 可緊貼外部標頭邊緣。
讀取headerlessTopInset()設定setHeaderlessTopInset()變更訊號headerlessTopInsetChanged()QString placeholderText模型沒有項目時顯示的預留文字。
讀取placeholderText()設定setPlaceholderText()變更訊號placeholderTextChanged()bool canReorderItems是否啟用拖曳重新排序。
讀取canReorderItems()設定setCanReorderItems()變更訊號canReorderItemsChanged()bool scrollChainingEnabled邊界處的滾輪輸入是否可繼續傳遞至外層捲動容器。
讀取isScrollChainingEnabled()設定setScrollChainingEnabled()變更訊號scrollChainingEnabledChanged()bool overscrollEnabled在捲動邊界是否啟用彈性回彈效果。預設為啟用;若希望捲動於邊緣俐落停止則可停用。
讀取isOverscrollEnabled()設定setOverscrollEnabled()變更訊號overscrollEnabledChanged()
訊號
void selectionModeChanged()集合檢視使用的選取模式。
void fontRoleChanged()用於文字繪製的 Fluent 排版角色。
void viewportHoveredChanged()檢視區目前是否處於懸停狀態。
void borderVisibleChanged()是否繪製控制項外框邊線。
void backgroundVisibleChanged()是否繪製控制項背景。
void headerTextChanged()欄標頭與資料列上方的可選標題。欄標頭預設隱藏;可使用 setHeaderHidden(false) 顯示模型標頭資料。
void headerlessTopInsetChanged()標題與欄標頭皆隱藏時首列上方的間距,預設為 2 個邏輯像素。設為 0 可緊貼外部標頭邊緣。
void placeholderTextChanged()模型沒有項目時顯示的預留文字。
void itemPressed(const QModelIndex& index)鏡像 QAbstractItemView::pressed() 的便利訊號。
void itemClicked(const QModelIndex& index)鏡像 QAbstractItemView::clicked() 的便利訊號。
void canReorderItemsChanged()是否啟用拖曳重新排序。
void scrollChainingEnabledChanged()邊界處的滾輪輸入是否可繼續傳遞至外層捲動容器。
void overscrollEnabledChanged()在捲動邊界是否啟用彈性回彈效果。預設為啟用;若希望捲動於邊緣俐落停止則可停用。
void indicatorMotionProgressChanged()樹狀結構選取指示器的動畫進度。
void indicatorMotionDirectionChanged()樹狀指示器動態效果使用的垂直方向。
void indicatorHierarchyTransitionChanged()樹狀指示器動態效果使用的階層轉場模式。
void indicatorMotionAnimationEnabledChanged()是否啟用樹狀指示器動態動畫。
型別與別名
struct SelectionIndicatorStyle移動選取指示器覆蓋層使用的樣式參數。
PySide6 擴充
受保護成員
方法
繼承自 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 基底類別文件:QTreeView
fluent::collections::TreeView::SelectionIndicatorStyle
移動選取指示器覆蓋層使用的樣式參數。