Fluent-Qt

Basic input

ComboBox

A drop-down list for selecting one item from a set of options.

Example

ComboBox: ComboBox selection

Usage

ComboBox selection

Add options with addItems(), listen to currentIndexChanged, and read the selected label via currentText(). Placeholder text shows when nothing is selected and input is empty (in editable mode, set it on lineEdit()).

#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());
        });

fluent::basicinput::ComboBox

Inherits QComboBox · FluentElement · QMLPlus

Fluent combo box with a custom popup list, optional editable input, and trailing slot.

Constructors

Properties

Typography::FontRole fontRole

Fluent Typography preset used for text.

Read fontRole()Write setFontRole()Notify fontRoleChanged()
int contentPaddingH

Horizontal content padding in pixels.

Read contentPaddingH()Write setContentPaddingH()Notify layoutChanged()
int contentPaddingV

Vertical content padding in pixels.

Read contentPaddingV()Write setContentPaddingV()Notify layoutChanged()
QString chevronGlyph

Iconfont glyph used for the chevron affordance.

Read chevronGlyph()Write setChevronGlyph()Notify chevronChanged()
int chevronSize

Chevron glyph pixel size.

Read chevronSize()Write setChevronSize()Notify chevronChanged()
QPoint chevronOffset

Pixel offset applied to chevron drawing.

Read chevronOffset()Write setChevronOffset()Notify chevronChanged()
int popupOffset

Popup offset from its anchor in pixels.

Read popupOffset()Write setPopupOffset()Notify layoutChanged()
qreal pressProgress

Animated press progress for chevron click feedback.

Read pressProgress()Write setPressProgress()
QString trailingText
Read trailingText()Write setTrailingText()Notify trailingTextChanged()
QWidget* trailingWidget
Read trailingWidget()Notify trailingWidgetChanged()
fluent::WidgetOwnership trailingWidgetOwnership
Read trailingWidgetOwnership()Notify trailingWidgetOwnershipChanged()

Methods

Typography::FontRole fontRole() const

Fluent Typography preset used for text.

void setFontRole(Typography::FontRole role)

Applies the Fluent Typography preset and clears any explicit font override, even if unchanged.

void setFont(const QFont& font)

Sets the field, editor and dropdown font independently of theme refreshes.

int contentPaddingH() const

Horizontal content padding in pixels.

void setContentPaddingH(int px)

Horizontal content padding in pixels.

int contentPaddingV() const

Vertical content padding in pixels.

void setContentPaddingV(int px)

Vertical content padding in pixels.

QString chevronGlyph() const

Iconfont glyph used for the chevron affordance.

void setChevronGlyph(const QString& glyph)

Iconfont glyph used for the chevron affordance.

int chevronSize() const

Chevron glyph pixel size.

void setChevronSize(int size)

Chevron glyph pixel size.

QPoint chevronOffset() const

Pixel offset applied to chevron drawing.

void setChevronOffset(const QPoint& offset)

Pixel offset applied to chevron drawing.

int popupOffset() const

Popup offset from its anchor in pixels.

void setPopupOffset(int offset)

Popup offset from its anchor in pixels.

qreal pressProgress() const

Animated press progress for chevron click feedback.

void setPressProgress(qreal p)

Animated press progress for chevron click feedback.

void setEditable(bool editable)

Enables or disables editable mode using a Fluent LineEdit.

void setLineEdit(QLineEdit* edit)

Replaces the QComboBox editor and synchronizes Fluent layout state.

void setTrailingText(const QString& text)

Displays a plain-text suffix in both editable and non-editable modes without changing item values.

bool setTrailingWidget(QWidget* widget, WidgetOwnership ownership)

Places a trailing widget beside the text or editor, replacing any suffix text. Pass WidgetOwnership to specify cleanup; call takeTrailingWidget() before changing it.

QWidget* takeTrailingWidget()

Removes and returns the trailing widget for the caller to manage or delete.

void releaseTrailingWidget()

Removes the trailing widget and handles cleanup according to its WidgetOwnership mode.

void setModel(QAbstractItemModel* model) FLUENT_QT6_ONLY_OVERRIDE

Sets the item model (still managed by the caller; not deleted by this control).

Signals

void fontRoleChanged()

Fluent Typography preset used for text.

void layoutChanged()

Horizontal content padding in pixels.

void chevronChanged()

Iconfont glyph used for the chevron affordance.

Destructors

PySide6 additions

Protected members

Methods

Inherited from fluent::FluentElement

Methods

static void setTheme(Theme theme)

Updates the global theme and notifies active FluentElement instances.

static void setThemeDeferred(Theme theme)

Schedules a visible-first batched theme refresh without blocking the current interaction.

static Theme currentTheme()

Returns the currently active global theme.

static bool themeUsesDarkAppearance(Theme theme)

Returns whether a theme uses dark-backed chrome and material tokens.

static void refreshTheme()

Re-broadcasts the current theme to repaint after a design-token change.

static int themeGeneration()

Monotonic counter bumped on every theme change, for staleness checks.

Theme effectiveTheme() const

Resolves the theme used by this element, honoring an inherited QWidget override.

bool effectiveThemeUsesDarkAppearance() const

Returns whether this element's effective theme uses dark-backed chrome.

bool setThemeOverrides(const QJsonObject& overrides)

Replaces this element's sparse color, radius, and font token overrides.

QJsonObject themeOverrides() const

Returns this element's authored overrides.

void clearThemeOverrides()

Restores all token fields to global theme defaults.

const Colors& themeColorsRef() const

Non-copying access to the active color set for hot paint paths.

Material::AcrylicToken themeAcrylic() const

Material, elevation, and adaptive layout tokens.

QColor themeBackdrop(bool active) const

Window-chrome backdrop color for the given activation state.

virtual void onThemeUpdated()

Called after the global theme changes.

Enumerations

enum Theme

Global visual theme used when resolving design tokens.

  • Light = 0
  • Dark = 1
  • HighContrast = 2

Types and aliases

struct Colors

Design token snapshots returned to components.

Inherited from fluent::QMLPlus

Methods

AnchorLayout::Anchors* anchors()

Returns mutable anchors for the QWidget host.

void setState(const QString& name)

Applies a registered state by name, or restores the default state when @p name is empty. Unknown names are ignored, and existing bindings resume when leaving the state.

void addState(const QMLState& state)

Registers or replaces a named state definition; replacing the active state applies it immediately.

void evaluateStates()

Reevaluates state conditions in registration order and activates the first match, or the default state if none match. Also runs automatically when dependency properties notify; derived states using extend inherit ancestor changes unless cyclic or missing.

QMLPlusRuntime* runtime()

Returns the lazily created state observer owned by this host.

void setAnchors(const AnchorLayout::Anchors& anchors)

Replaces all host anchors and invalidates the parent layout.

void resetAnchors()

Clears all host anchors and invalidates the parent layout.

void bind(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction dir = PropertyBinder::OneWay)

Binds @p sourceProp on @p source to @p targetProp on this QWidget host via PropertyBinder::bind().

void addTransition(const StateTransition& transition)

Registers a state transition in precedence order.

void setBehavior(const char* propertyName, const PropertyAnimation& animation)

Sets the default animation used when @p propertyName is written via writeProperty() or a binding. Explicit StateTransition rules take precedence; direct C++ setter calls are not animated.

void clearBehavior(const char* propertyName)

Removes the default animation for future managed writes.

bool writeProperty(const char* propertyName, const QVariant& value)

Writes a host property through Behavior without removing its binding.

Qt base class docs: QComboBox

fluent::basicinput::ComboBoxItemDelegate

Inherits QStyledItemDelegate

Item delegate that renders ComboBox popup rows with Fluent metrics and theme colors.

Constructors

Methods