集合视图
TreeView 树形视图
浏览、展开和选择层级数据。
示例

用法
文件夹层级
setModel() 提供树形数据,点击箭头展开或收起;示例用自定义 delegate 绘制箭头和图标。
#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
具备层级感知选中视觉的 Fluent 树形集合视图。
构造函数
属性
SelectionMode selectionMode集合视图使用的选择模式。
读取selectionMode()设置setSelectionMode()通知selectionModeChanged()Typography::FontRole fontRole文本绘制使用的 Fluent 排版角色。
读取fontRole()设置setFontRole()通知fontRoleChanged()bool viewportHovereditem-view viewport 当前是否处于悬停状态。
读取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显示在头部区域的便捷标题文本。
读取headerText()设置setHeaderText()通知headerTextChanged()QString placeholderText树形 model 没有可展示行时显示的占位文本。
读取placeholderText()设置setPlaceholderText()通知placeholderTextChanged()bool canReorderItems是否启用拖拽重排。
读取canReorderItems()设置setCanReorderItems()通知canReorderItemsChanged()bool scrollChainingEnabled边界滚轮输入是否允许继续传递给外层滚动容器。
读取isScrollChainingEnabled()设置setScrollChainingEnabled()通知scrollChainingEnabledChanged()bool overscrollEnabled滚动到边界时是否显示弹性回弹。默认开启;用于不希望回弹的 chrome(如导航窗格)时关闭, 使其在边界干脆停住、反向滚动立即响应。
读取isOverscrollEnabled()设置setOverscrollEnabled()通知overscrollEnabledChanged()
方法
SelectionMode selectionMode() const--- Selection ---
void setSelectionMode(SelectionMode mode)集合视图使用的选择模式。
Typography::FontRole fontRole() const--- Appearance ---
void setFontRole(Typography::FontRole role)文本绘制使用的 Fluent 排版角色。
bool borderVisible() const是否绘制控件外框边线。
void setBorderVisible(bool visible)是否绘制控件外框边线。
bool backgroundVisible() const是否绘制控件背景。
QString headerText() const显示在头部区域的便捷标题文本。
void setHeaderText(const QString& text)显示在头部区域的便捷标题文本。
QString placeholderText() const树形 model 没有可展示行时显示的占位文本。
void setPlaceholderText(const QString& text)树形 model 没有可展示行时显示的占位文本。
bool viewportHovered() constitem-view viewport 当前是否处于悬停状态。
bool canReorderItems() const--- Drag reorder ---
bool isScrollChainingEnabled() const边界滚轮输入是否允许继续传递给外层滚动容器。
void setScrollChainingEnabled(bool enabled)边界滚轮输入是否允许继续传递给外层滚动容器。
bool isOverscrollEnabled() const滚动到边界时是否显示弹性回弹。默认开启;用于不希望回弹的 chrome(如导航窗格)时关闭, 使其在边界干脆停住、反向滚动立即响应。
void setOverscrollEnabled(bool enabled)滚动到边界时是否显示弹性回弹。默认开启;用于不希望回弹的 chrome(如导航窗格)时关闭, 使其在边界干脆停住、反向滚动立即响应。
void expandAll()--- Tree API ---
QModelIndex selectedItem() const--- Selection API ---
qreal indicatorMotionProgress() const--- Selected indicator motion API ---
bool isIndicatorMotionAnimationEnabled() const是否启用树指示器动效动画。
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) constQuery chevron rotation progress for delegate painting. 0=right, 1=down.
信号
void selectionModeChanged()集合视图使用的选择模式。
void fontRoleChanged()文本绘制使用的 Fluent 排版角色。
void viewportHoveredChanged()item-view viewport 当前是否处于悬停状态。
void borderVisibleChanged()是否绘制控件外框边线。
void backgroundVisibleChanged()是否绘制控件背景。
void headerTextChanged()显示在头部区域的便捷标题文本。
void placeholderTextChanged()树形 model 没有可展示行时显示的占位文本。
void itemPressed(const QModelIndex& index)使用同一模型索引镜像继承的 pressed() 信号。
void itemClicked(const QModelIndex& index)使用同一模型索引镜像继承的 clicked() 信号。
void canReorderItemsChanged()是否启用拖拽重排。
void scrollChainingEnabledChanged()边界滚轮输入是否允许继续传递给外层滚动容器。
void overscrollEnabledChanged()滚动到边界时是否显示弹性回弹。默认开启;用于不希望回弹的 chrome(如导航窗格)时关闭, 使其在边界干脆停住、反向滚动立即响应。
void indicatorMotionProgressChanged()树选中指示器的动画进度。
void indicatorMotionDirectionChanged()树指示器动效使用的垂直方向。
void indicatorHierarchyTransitionChanged()树指示器动效使用的层级转场模式。
void indicatorMotionAnimationEnabledChanged()是否启用树指示器动效动画。
枚举
enum class IndicatorVerticalDirectionNoneUpDown
enum class IndicatorHierarchyTransitionNoneSameLevelInwardOutward
类型与别名
struct SelectionIndicatorStyle移动选中指示器覆盖层使用的样式参数。
析构函数
PySide6 扩展
子类扩展接口
方法
继承自 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 基类完整成员:QTreeView
fluent::collections::TreeView::SelectionIndicatorStyle
移动选中指示器覆盖层使用的样式参数。