基础输入
ComboBox 下拉选择框
从下拉列表中选择一项。
示例

用法
读取选中项
addItems() 添加选项;选择变化时 currentIndexChanged 触发,用 currentText() 读取文字。
#include <FluentQt/BasicInput.h>
using namespace fluent::basicinput;
auto* comboBox = new ComboBox(this);
comboBox->addItems({"Blue", "Green", "Red", "Yellow"});
comboBox->setCurrentIndex(0);
connect(comboBox, qOverload<int>(&ComboBox::currentIndexChanged),
this, [=](int index) {
status->setText(comboBox->currentText());
});import fluentqt
combo_box = fluentqt.ComboBox()
combo_box.addItems(['Blue', 'Green', 'Red', 'Yellow'])
combo_box.setCurrentIndex(0)
combo_box.currentIndexChanged.connect(
lambda _index: status.setText(f"Selected: {combo_box.currentText()}")
)API
查看声明没有匹配的 API 成员。
fluent::basicinput::ComboBox
继承自 QComboBox · FluentElement · QMLPlus
使用自定义弹层和 token 驱动按钮表面的 Fluent 组合框。
构造函数
属性
Typography::FontRole fontRole文本绘制使用的 Fluent 排版角色。
读取fontRole()设置setFontRole()通知fontRoleChanged()int contentPaddingH内容区域水平内边距,单位为像素。
读取contentPaddingH()设置setContentPaddingH()通知layoutChanged()int contentPaddingV内容区域垂直内边距,单位为像素。
读取contentPaddingV()设置setContentPaddingV()通知layoutChanged()QString chevronGlyph下拉箭头使用的 iconfont 字符。
读取chevronGlyph()设置setChevronGlyph()通知chevronChanged()int chevronSize下拉箭头图标像素尺寸。
读取chevronSize()设置setChevronSize()通知chevronChanged()QPoint chevronOffset下拉箭头绘制时应用的像素偏移。
读取chevronOffset()设置setChevronOffset()通知chevronChanged()int popupOffset弹层相对锚点的像素偏移。
读取popupOffset()设置setPopupOffset()通知layoutChanged()qreal pressProgress自绘表面使用的按压动画进度。
读取pressProgress()设置setPressProgress()QString trailingText- 读取
trailingText()设置setTrailingText()通知trailingTextChanged() QWidget* trailingWidget- 读取
trailingWidget()通知trailingWidgetChanged() fluent::WidgetOwnership trailingWidgetOwnership- 读取
trailingWidgetOwnership()通知trailingWidgetOwnershipChanged()
方法
Typography::FontRole fontRole() const--- Appearance ---
void setFontRole(Typography::FontRole role)恢复主题排版;角色未变化时也会清除显式字体覆盖。
void setFont(const QFont& font)设置闭合框、编辑框和下拉列表的字体,主题刷新后仍保留。
int contentPaddingH() const内容区域水平内边距,单位为像素。
void setContentPaddingH(int px)内容区域水平内边距,单位为像素。
int contentPaddingV() const内容区域垂直内边距,单位为像素。
void setContentPaddingV(int px)内容区域垂直内边距,单位为像素。
QString chevronGlyph() const下拉箭头使用的 iconfont 字符。
void setChevronGlyph(const QString& glyph)下拉箭头使用的 iconfont 字符。
int chevronSize() const下拉箭头图标像素尺寸。
void setChevronSize(int size)下拉箭头图标像素尺寸。
QPoint chevronOffset() const下拉箭头绘制时应用的像素偏移。
void setChevronOffset(const QPoint& offset)下拉箭头绘制时应用的像素偏移。
int popupOffset() const弹层相对锚点的像素偏移。
void setPopupOffset(int offset)弹层相对锚点的像素偏移。
qreal pressProgress() const自绘表面使用的按压动画进度。
void setPressProgress(qreal p)自绘表面使用的按压动画进度。
void setEditable(bool editable)使用 Fluent 编辑器启用原生 QComboBox 可编辑契约。
void setLineEdit(QLineEdit* edit)替换 QComboBox 编辑器并同步 Fluent 布局状态。
void setTrailingText(const QString& text)在两种编辑模式中显示纯文字尾缀,不改变选项值。
bool setTrailingWidget(QWidget* widget, WidgetOwnership ownership)在编辑器之外承载一个尾部控件,并替换文字尾缀。
QWidget* takeTrailingWidget()脱离自定义尾部内容并交回调用方。
void releaseTrailingWidget()按记录的所有权策略释放自定义尾部内容。
QAbstractItemModel* model() const--- QComboBox overrides ---
信号
void fontRoleChanged()文本绘制使用的 Fluent 排版角色。
void layoutChanged()内容区域水平内边距,单位为像素。
void chevronChanged()下拉箭头使用的 iconfont 字符。
析构函数
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 基类完整成员:QComboBox
fluent::basicinput::ComboBoxItemDelegate
ComboBox 弹层代理 ─────────────────────