Fluent-Qt

Navigation

TabView

A control that hosts multiple pages of content behind a tab strip.

Example

TabView: TabView with hosted pages

Usage

TabView with hosted pages

currentChanged selects the external StackContentHost page; tabMoved keeps tab order and page order aligned.

#include <FluentQt/Navigation.h>
using namespace fluent::navigation;

auto* surface = new QWidget(this);
surface->setMinimumWidth(360);
surface->setMaximumWidth(560);
surface->setFixedHeight(186);
surface->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
auto* layout = new QVBoxLayout(surface);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);

auto* tabs = new TabView(surface);
tabs->setFixedHeight(40);
tabs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
tabs->setTabWidthMode(TabView::TabWidthMode::SizeToContent);
tabs->setTabReorderEnabled(true);
tabs->setTabsClosable(false);
tabs->setAddTabButtonVisible(false);
tabs->addTab(TabViewItem("Home", Typography::Icons::Home));
tabs->addTab(TabViewItem("Details", Typography::Icons::Document));
tabs->addTab(TabViewItem("Activity", Typography::Icons::Calendar));

auto* host = new StackContentHost(surface);
host->setFixedHeight(146);
host->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
for (int i = 0; i < tabs->tabCount(); ++i)
    host->insertPage(i, createPage(tabs->tabAt(i).text));

connect(tabs, &TabView::currentChanged,
        host, [host](int index) { host->setCurrentIndex(index, 0, true); });
connect(tabs, &TabView::tabMoved,
        host, [host](int from, int to) { host->movePage(from, to); });
layout->addWidget(tabs);
layout->addWidget(host);

fluent::navigation::TabView

Inherits QWidget · FluentElement · fluent::QMLPlus

Fluent tab metadata surface with close, reorder, and overflow behavior.

Constructors

Properties

int tabCount

Number of tabs currently managed by TabView.

Read tabCount()Notify tabsChanged()
int selectedIndex

Currently selected tab index.

Read selectedIndex()Write setSelectedIndex()Notify selectedIndexChanged()
TabWidthMode tabWidthMode

Width sizing mode used by tabs.

Read tabWidthMode()Write setTabWidthMode()Notify tabWidthModeChanged()
CloseButtonOverlayMode closeButtonOverlayMode

Visibility behavior for tab close buttons.

Read closeButtonOverlayMode()Write setCloseButtonOverlayMode()Notify closeButtonOverlayModeChanged()
bool tabsClosable

Whether tabs expose close affordances.

Read tabsClosable()Write setTabsClosable()Notify tabsClosableChanged()
bool addTabButtonVisible

Whether the add-tab button is visible.

Read addTabButtonVisible()Write setAddTabButtonVisible()Notify addTabButtonVisibleChanged()
bool tabReorderEnabled

Whether users can reorder tabs.

Read tabReorderEnabled()Write setTabReorderEnabled()Notify tabReorderEnabledChanged()
bool keyboardAcceleratorsEnabled

Whether tab keyboard accelerators are enabled.

Read keyboardAcceleratorsEnabled()Write setKeyboardAcceleratorsEnabled()Notify keyboardAcceleratorsEnabledChanged()
Typography::FontRole tabFontRole

Typography role used by tab text.

Read tabFontRole()Write setTabFontRole()Notify tabFontRoleChanged()
QString iconFontFamily

Icon font family used by tab glyphs.

Read iconFontFamily()Write setIconFontFamily()Notify iconFontFamilyChanged()

Methods

int tabCount() const

Number of tabs currently managed by TabView.

int selectedIndex() const

Currently selected tab index.

void setSelectedIndex(int index)

Currently selected tab index.

TabWidthMode tabWidthMode() const

Width sizing mode used by tabs.

void setTabWidthMode(TabWidthMode mode)

Width sizing mode used by tabs.

CloseButtonOverlayMode closeButtonOverlayMode() const

Visibility behavior for tab close buttons.

void setCloseButtonOverlayMode(CloseButtonOverlayMode mode)

Visibility behavior for tab close buttons.

bool tabsClosable() const

Whether tabs expose close affordances.

void setTabsClosable(bool closable)

Whether tabs expose close affordances.

bool addTabButtonVisible() const

Whether the add-tab button is visible.

void setAddTabButtonVisible(bool visible)

Whether the add-tab button is visible.

bool tabReorderEnabled() const

Whether users can reorder tabs.

void setTabReorderEnabled(bool enabled)

Whether users can reorder tabs.

bool keyboardAcceleratorsEnabled() const

Whether tab keyboard accelerators are enabled.

void setKeyboardAcceleratorsEnabled(bool enabled)

Whether tab keyboard accelerators are enabled.

Typography::FontRole tabFontRole() const

Typography role used by tab text.

void setTabFontRole(Typography::FontRole role)

Typography role used by tab text.

QString iconFontFamily() const

Icon font family used by tab glyphs.

void setIconFontFamily(const QString& family)

Icon font family used by tab glyphs.

Signals

void tabsChanged()

Number of tabs currently managed by TabView.

void selectedIndexChanged(int index)

Currently selected tab index.

void tabWidthModeChanged(TabWidthMode mode)

Width sizing mode used by tabs.

void closeButtonOverlayModeChanged(CloseButtonOverlayMode mode)

Visibility behavior for tab close buttons.

void tabsClosableChanged(bool closable)

Whether tabs expose close affordances.

void addTabButtonVisibleChanged(bool visible)

Whether the add-tab button is visible.

void tabReorderEnabledChanged(bool enabled)

Whether users can reorder tabs.

void keyboardAcceleratorsEnabledChanged(bool enabled)

Whether tab keyboard accelerators are enabled.

void iconFontFamilyChanged(const QString& family)

Icon font family used by tab glyphs.

Enumerations

enum class TabWidthMode
  • Equal
  • SizeToContent
  • Compact

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

fluent::navigation::TabViewItem

Constructors

Fields

fluent::navigation::TabStrip

Inherits QWidget · FluentElement

Internal tab strip that paints tab chrome and indicator geometry.

Constructors

Properties

QRect animatedIndicatorRect

Current animated indicator rectangle in TabStrip coordinates.

Read animatedIndicatorRect()Write setAnimatedIndicatorRect()

Methods

Signals

Enumerations

enum class WidthMode
  • Equal
  • SizeToContent
  • Compact
Subclass interfaces

Methods