Fluent-Qt

Basic input

MultiSelectComboBox

A model-backed drop-down list for selecting, filtering, and clearing several options.

Example

MultiSelectComboBox: Select several model rows

Usage

Select several model rows

The selected rows are the value; toggling an item keeps the dropdown open.

#include <FluentQt/BasicInput.h>
using namespace fluent::basicinput;

auto* model = new QStringListModel(
    {"Design", "Engineering", "Research", "Support"}, this);
auto* box = new MultiSelectComboBox(this);
box->setModel(model);
box->setPlaceholderText("Choose teams");
box->setAccessibleName("Teams");
box->setSelectedRows({0, 2});
box->setFixedWidth(280);

auto* status = new Label(this);
status->setFixedWidth(280);
status->setWordWrap(true);

auto updateStatus = [box, status] {
    QStringList labels;
    for (const QModelIndex& index : box->selectedIndexes())
        labels << index.data().toString();
    status->setText(QStringLiteral("Selected: %1")
                        .arg(labels.join(", ")));
};
connect(box, &MultiSelectComboBox::selectionChanged,
        this, [=] { updateStatus(); });
updateStatus();

fluent::basicinput::MultiSelectComboBox

Inherits QWidget · FluentElement · QMLPlus

Model-backed Fluent dropdown for selecting several rows.

Constructors

Properties

QAbstractItemModel* model

Caller-owned source model displayed by the dropdown.

Read model()Write setModel()Notify modelChanged()
QItemSelectionModel* selectionModel

Selection model used as the component value.

Read selectionModel()Write setSelectionModel()Notify selectionModelChanged()
int modelColumn

Source-model column used for labels and filtering.

Read modelColumn()Write setModelColumn()Notify modelColumnChanged()
QModelIndex rootModelIndex

Source-model root whose direct children form the option list.

Read rootModelIndex()Write setRootModelIndex()Notify rootModelIndexChanged()
QString placeholderText

Text shown while no selectable row is selected.

Read placeholderText()Write setPlaceholderText()Notify placeholderTextChanged()
bool searchEnabled

Whether a local substring-search field is shown in the popup.

Read isSearchEnabled()Write setSearchEnabled()Notify searchEnabledChanged()
QString searchPlaceholderText

Placeholder text used by the popup search field.

Read searchPlaceholderText()Write setSearchPlaceholderText()Notify searchPlaceholderTextChanged()
bool selectAllVisible

Whether the popup shows a tri-state select-all action.

Read isSelectAllVisible()Write setSelectAllVisible()Notify selectAllVisibleChanged()
int maximumVisibleItems

Maximum number of option rows visible before scrolling.

Read maximumVisibleItems()Write setMaximumVisibleItems()Notify maximumVisibleItemsChanged()
bool isOpen

Logical popup open state.

Read isOpen()Write setIsOpen()Notify isOpenChanged()
int selectedCount

Number of selected selectable rows under rootModelIndex.

Read selectedCount()Notify selectedCountChanged()

Methods

QAbstractItemModel* model() const

Caller-owned source model displayed by the dropdown.

void setModel(QAbstractItemModel* model)

Caller-owned source model displayed by the dropdown.

QItemSelectionModel* selectionModel() const

Selection model used as the component value.

void setSelectionModel(QItemSelectionModel* selectionModel)

Selection model used as the component value.

int modelColumn() const

Source-model column used for labels and filtering.

void setModelColumn(int column)

Source-model column used for labels and filtering.

QModelIndex rootModelIndex() const

Source-model root whose direct children form the option list.

void setRootModelIndex(const QModelIndex& index)

Source-model root whose direct children form the option list.

QString placeholderText() const

Text shown while no selectable row is selected.

void setPlaceholderText(const QString& text)

Text shown while no selectable row is selected.

bool isSearchEnabled() const

Whether a local substring-search field is shown in the popup.

void setSearchEnabled(bool enabled)

Whether a local substring-search field is shown in the popup.

QString searchPlaceholderText() const

Placeholder text used by the popup search field.

void setSearchPlaceholderText(const QString& text)

Placeholder text used by the popup search field.

bool isSelectAllVisible() const

Whether the popup shows a tri-state select-all action.

void setSelectAllVisible(bool visible)

Whether the popup shows a tri-state select-all action.

int maximumVisibleItems() const

Maximum number of option rows visible before scrolling.

void setMaximumVisibleItems(int count)

Maximum number of option rows visible before scrolling.

bool isOpen() const

Logical popup open state.

int selectedCount() const

Number of selected selectable rows under rootModelIndex.

void setSelectedRows(const QList<int>& rows)

Replaces selected rows under the active root.

void clearSelection()

Clears selected rows under the active root.

void selectAll()

Selects every enabled and selectable source row under the root.

void open()

Opens the anchored dropdown.

void close()

Closes the dropdown without rolling back selection.

void setIsOpen(bool open)

Logical popup open state.

Signals

void modelChanged(QAbstractItemModel* model)

Caller-owned source model displayed by the dropdown.

void selectionModelChanged(QItemSelectionModel* selectionModel)

Selection model used as the component value.

void modelColumnChanged(int column)

Source-model column used for labels and filtering.

void rootModelIndexChanged(const QModelIndex& index)

Source-model root whose direct children form the option list.

void selectedCountChanged(int count)

Number of selected selectable rows under rootModelIndex.

void placeholderTextChanged(const QString& text)

Text shown while no selectable row is selected.

void searchEnabledChanged(bool enabled)

Whether a local substring-search field is shown in the popup.

void searchPlaceholderTextChanged(const QString& text)

Placeholder text used by the popup search field.

void selectAllVisibleChanged(bool visible)

Whether the popup shows a tri-state select-all action.

void maximumVisibleItemsChanged(int count)

Maximum number of option rows visible before scrolling.

void isOpenChanged(bool open)

Logical popup open state.

Destructors

Subclass interfaces

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.

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 named state, or clears state when name is empty.

void addState(const QMLState& state)

Registers or replaces a named state definition.

void evaluateStates()

Reevaluates conditions; the first registered true condition wins.

QMLPlusRuntime* runtime()

Returns the lazy host-owned state observation object.

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 addTransition(const StateTransition& transition)

Registers a state transition in precedence order.

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

Sets the default animation for this host's managed property writes.

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.

All inherited Qt members:QWidget