Fluent-Qt

Collections

GridView

Presents items in a grid of uniform cells with selection.

Example

GridView: GridView photo grid

Usage

GridView photo grid

Photo cards align to a uniform grid; a custom delegate paints the cover image and caption.

#include <FluentQt/Collections.h>
using namespace fluent::collections;

auto* gridView = new GridView(this);
gridView->setCellSize(QSize(150, 112));
gridView->setItemDelegate(photoDelegate);
gridView->setModel(model);
gridView->setSelectedIndex(0);

fluent::collections::GridView

Inherits QListView · FluentElement · QMLPlus

Fluent grid collection view with configurable cell metrics.

Constructors

Properties

SelectionMode selectionMode

Selection mode used by the collection view.

Read selectionMode()Write setSelectionMode()Notify selectionModeChanged()
Typography::FontRole fontRole

Fluent typography role used for text rendering.

Read fontRole()Write setFontRole()Notify fontRoleChanged()
bool viewportHovered

Whether the item-view viewport is currently hovered.

Read viewportHovered()Notify viewportHoveredChanged()
bool canReorderItems

Whether drag reordering is enabled.

Read canReorderItems()Write setCanReorderItems()Notify canReorderItemsChanged()
bool scrollChainingEnabled

Whether boundary wheel input may continue to an enclosing scroller.

Read isScrollChainingEnabled()Write setScrollChainingEnabled()Notify scrollChainingEnabledChanged()
bool overscrollEnabled

Whether the view shows an elastic overscroll/bounce at the scroll boundary. Enabled by default; disable for chrome that should stop cleanly at the edge.

Read isOverscrollEnabled()Write setOverscrollEnabled()Notify overscrollEnabledChanged()
bool borderVisible

Whether the control frame border is painted.

Read borderVisible()Write setBorderVisible()Notify borderVisibleChanged()
bool backgroundVisible

Whether the control background is painted.

Read backgroundVisible()Write setBackgroundVisible()Notify backgroundVisibleChanged()
QString headerText

Convenience text displayed in the header area.

Read headerText()Write setHeaderText()Notify headerTextChanged()
QString placeholderText

Text shown when the grid model has no rows to present.

Read placeholderText()Write setPlaceholderText()Notify placeholderTextChanged()
QSize cellSize

Grid cell size used for item layout.

Read cellSize()Write setCellSize()Notify cellSizeChanged()
int horizontalSpacing

Horizontal spacing between items.

Read horizontalSpacing()Write setHorizontalSpacing()Notify horizontalSpacingChanged()
int verticalSpacing

Vertical spacing between items.

Read verticalSpacing()Write setVerticalSpacing()Notify verticalSpacingChanged()
int maxColumns

Maximum number of columns; zero means unconstrained.

Read maxColumns()Write setMaxColumns()Notify maxColumnsChanged()

Methods

void setSelectionMode(SelectionMode mode)

Selection mode used by the collection view.

void setFontRole(Typography::FontRole role)

Fluent typography role used for text rendering.

bool borderVisible() const

Whether the control frame border is painted.

void setBorderVisible(bool visible)

Whether the control frame border is painted.

bool backgroundVisible() const

Whether the control background is painted.

void setBackgroundVisible(bool visible)

Whether the control background is painted.

QString headerText() const

Convenience text displayed in the header area.

void setHeaderText(const QString& text)

Convenience text displayed in the header area.

QString placeholderText() const

Text shown when the grid model has no rows to present.

void setPlaceholderText(const QString& text)

Text shown when the grid model has no rows to present.

bool viewportHovered() const

Whether the item-view viewport is currently hovered.

bool canReorderItems() const

--- Drag reorder ---

void setCanReorderItems(bool enabled)

Whether drag reordering is enabled.

bool isScrollChainingEnabled() const

Whether boundary wheel input may continue to an enclosing scroller.

void setScrollChainingEnabled(bool enabled)

Whether boundary wheel input may continue to an enclosing scroller.

bool isOverscrollEnabled() const

Whether the view shows an elastic overscroll/bounce at the scroll boundary. Enabled by default; disable for chrome that should stop cleanly at the edge.

void setOverscrollEnabled(bool enabled)

Whether the view shows an elastic overscroll/bounce at the scroll boundary. Enabled by default; disable for chrome that should stop cleanly at the edge.

QSize cellSize() const

--- Grid layout ---

void setCellSize(const QSize& size)

Grid cell size used for item layout.

int horizontalSpacing() const

Horizontal spacing between items.

void setHorizontalSpacing(int spacing)

Horizontal spacing between items.

int verticalSpacing() const

Vertical spacing between items.

void setVerticalSpacing(int spacing)

Vertical spacing between items.

int maxColumns() const

Maximum number of columns; zero means unconstrained.

void setMaxColumns(int maxCols)

Maximum number of columns; zero means unconstrained.

int selectedIndex() const

--- Selection API ---

Signals

void selectionModeChanged()

Selection mode used by the collection view.

void fontRoleChanged()

Fluent typography role used for text rendering.

void viewportHoveredChanged()

Whether the item-view viewport is currently hovered.

void borderVisibleChanged()

Whether the control frame border is painted.

void backgroundVisibleChanged()

Whether the control background is painted.

void headerTextChanged()

Convenience text displayed in the header area.

void placeholderTextChanged()

Text shown when the grid model has no rows to present.

void cellSizeChanged()

Grid cell size used for item layout.

void horizontalSpacingChanged()

Horizontal spacing between items.

void verticalSpacingChanged()

Vertical spacing between items.

void maxColumnsChanged()

Maximum number of columns; zero means unconstrained.

void canReorderItemsChanged()

Whether drag reordering is enabled.

void scrollChainingEnabledChanged()

Whether boundary wheel input may continue to an enclosing scroller.

void overscrollEnabledChanged()

Whether the view shows an elastic overscroll/bounce at the scroll boundary. Enabled by default; disable for chrome that should stop cleanly at the edge.

void itemClicked(int index)

Emits the row once for the same pointer action as inherited clicked().

Types and aliases

Destructors

PySide6 additions

Subclass interfaces

Methods

void mousePressEvent(QMouseEvent* event) override

Drag-reorder (custom mouse handling)

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:QListView