版面配置
ListDetailView 清單詳細資料檢視
寬螢幕時並排顯示清單與詳細資料,窄螢幕時自動切換為單欄顯示。
範例
屬性預覽載入失敗。請再次點選屬性預覽重試。

用法
單欄與雙欄
使用 setCompactThreshold() 設定切換寬度;在雙欄與單欄間切換時詳細頁面控制項不會重建,編輯狀態會保留。
#include <FluentQt/Layout.h>
using namespace fluent::layout;
auto* panel = new QWidget(this);
auto* body = new QVBoxLayout(panel);
body->setContentsMargins(0, 0, 0, 0);
body->setSpacing(12);
auto* width = new ComboBox(panel);
width->setAccessibleName("Preview width");
width->addItems({"Wide preview", "Narrow preview"});
body->addWidget(width, 0, Qt::AlignLeft);
auto* view = new fluent::layout::ListDetailView(panel);
view->setCompactThreshold(520);
view->setMaximumWidth(640);
view->setFixedHeight(156);
body->addWidget(view, 0, Qt::AlignLeft);
auto* list = new QVBoxLayout(view->listPane());
list->addWidget(new Label("Notes", view->listPane()));
auto* open = new Button("Open meeting note", view->listPane());
list->addWidget(open);
list->addStretch();
auto* detail = new QVBoxLayout(view->detailPane());
auto* back = new Button("Back to notes", view->detailPane());
back->setFluentStyle(Button::Subtle);
back->setVisible(view->isCompact());
detail->addWidget(back, 0, Qt::AlignLeft);
detail->addWidget(new Label("Meeting note", view->detailPane()));
auto* editor = new LineEdit(view->detailPane());
editor->setAccessibleName("Note draft");
editor->setText("Discuss the next release");
detail->addWidget(editor);
detail->addStretch();
connect(open, &Button::clicked, view, &fluent::layout::ListDetailView::showDetail);
connect(back, &Button::clicked, view, &fluent::layout::ListDetailView::showList);
connect(view, &fluent::layout::ListDetailView::compactChanged, back, &QWidget::setVisible);
connect(width, qOverload<int>(&ComboBox::currentIndexChanged), view, [view](int index) {
view->setMaximumWidth(index == 0 ? 640 : 360);
});import fluentqt
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QVBoxLayout, QWidget
panel = QWidget()
body = QVBoxLayout(panel)
body.setContentsMargins(0, 0, 0, 0)
body.setSpacing(12)
width = fluentqt.ComboBox(panel)
width.setObjectName("listDetailPreviewWidth")
width.setAccessibleName("Preview width")
width.addItems(["Wide preview", "Narrow preview"])
body.addWidget(width, 0, Qt.AlignLeft)
view = fluentqt.ListDetailView(panel)
view.setObjectName("basicListDetailView")
view.setCompactThreshold(520)
view.setMaximumWidth(640)
view.setFixedHeight(156)
body.addWidget(view, 0, Qt.AlignLeft)
list_layout = QVBoxLayout(view.listPane())
list_layout.addWidget(fluentqt.Label("Notes", view.listPane()))
open_button = fluentqt.Button("Open meeting note", view.listPane())
list_layout.addWidget(open_button)
list_layout.addStretch()
detail_layout = QVBoxLayout(view.detailPane())
back = fluentqt.Button("Back to notes", view.detailPane())
back.setFluentStyle(fluentqt.Button.Subtle)
back.setVisible(view.isCompact())
detail_layout.addWidget(back, 0, Qt.AlignLeft)
detail_layout.addWidget(fluentqt.Label("Meeting note", view.detailPane()))
editor = fluentqt.LineEdit(view.detailPane())
editor.setAccessibleName("Note draft")
editor.setText("Discuss the next release")
detail_layout.addWidget(editor)
detail_layout.addStretch()
open_button.clicked.connect(view.showDetail)
back.clicked.connect(view.showList)
view.compactChanged.connect(back.setVisible)
width.currentIndexChanged.connect(
lambda index: view.setMaximumWidth(640 if index == 0 else 360)
)API
檢視宣告沒有符合的 API 成員。
fluent::layout::ListDetailView
繼承自 QWidget · FluentElement · QMLPlus
兩個常駐窗格,寬度低於臨界值時會切換為單窗格模式。
建構函式
列舉
enum Pane精簡模式下的目前欄位;寬螢幕模式會同時顯示兩欄。
ListDetail
方法
QWidget* listPane() const傳回清單窗格容器(由本控制項管理生命週期)。
QWidget* detailPane() const傳回詳細資料窗格容器(由本控制項管理生命週期)。
void setCompactThreshold(int width)設定低於此寬度時僅顯示 currentPane 的閾值;最小值為 1。
void setListPaneWidth(int width)設定寬版清單寬度,上限為可用寬度的一半。
屬性
bool compact- 讀取
isCompact()變更訊號compactChanged() int compactThreshold- 讀取
compactThreshold()設定setCompactThreshold()變更訊號compactThresholdChanged() int listPaneWidth- 讀取
listPaneWidth()設定setListPaneWidth()變更訊號listPaneWidthChanged() Pane currentPane- 讀取
currentPane()設定setCurrentPane()變更訊號currentPaneChanged()
訊號
繼承自 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