Basic input
Button
Run an action, such as saving or submitting a form.
Example
Property preview could not load. Select Property preview to retry.


Usage
Choose a style
Set the style with setFluentStyle(): Accent for the main action, Standard for other actions, and Subtle for less prominent ones.
#include <FluentQt/BasicInput.h>
using namespace fluent::basicinput;
auto* standard = new Button("Standard", this);
standard->setFluentStyle(Button::Standard);
auto* accent = new Button("Accent", this);
accent->setFluentStyle(Button::Accent);
auto* subtle = new Button("Subtle", this);
subtle->setFluentStyle(Button::Subtle);import fluentqt
standard = fluentqt.Button('Standard')
standard.setFluentStyle(fluentqt.Button.ButtonStyle.Standard)
accent = fluentqt.Button('Accent')
accent.setFluentStyle(fluentqt.Button.ButtonStyle.Accent)
subtle = fluentqt.Button('Subtle')
subtle.setFluentStyle(fluentqt.Button.ButtonStyle.Subtle)Interaction states
Button renders rest, hover, pressed, and disabled states directly. Call setFocusVisual(true) to show the focus ring when focused via keyboard.
#include <FluentQt/BasicInput.h>
using namespace fluent::basicinput;
auto* rest = new Button("Rest", this);
auto* hover = new Button("Hover", this);
hover->setInteractionState(Button::Hover);
auto* pressed = new Button("Pressed", this);
pressed->setInteractionState(Button::Pressed);
auto* focused = new Button("Focus", this);
focused->setFocusVisual(true);
auto* disabled = new Button("Disabled", this);
disabled->setInteractionState(Button::Disabled);import fluentqt
rest = fluentqt.Button("Rest")
hover = fluentqt.Button("Hover")
hover.setInteractionState(fluentqt.Button.InteractionState.Hover)
pressed = fluentqt.Button("Pressed")
pressed.setInteractionState(fluentqt.Button.InteractionState.Pressed)
focused = fluentqt.Button("Focus")
focused.setFocusVisual(True)
disabled = fluentqt.Button("Disabled")
disabled.setInteractionState(fluentqt.Button.InteractionState.Disabled)API
DeclarationNo matching API members.
fluent::basicinput::Button
Inherits QPushButton · FluentElement · QMLPlus
Fluent push button with token-driven painting and optional iconfont content. Keeps QPushButton interaction behavior while custom-painting in paintEvent().
Constructors
Properties
ButtonStyle fluentStyleVisual treatment: Standard, Accent, or Subtle.
ReadfluentStyle()WritesetFluentStyle()NotifyfluentStyleChanged()ButtonSize fluentSizeSize preset controlling height and padding, not font.
ReadfluentSize()WritesetFluentSize()NotifyfluentSizeChanged()Typography::FontRole fontRoleFluent Typography preset used while following theme fonts.
ReadfontRole()WritesetFontRole()NotifyfontRoleChanged()TextColorRole textColorRoleForeground emphasis for unfilled, unchecked buttons; filled and disabled keep contrast colors.
ReadtextColorRole()WritesetTextColorRole()NotifytextColorRoleChanged()ButtonLayout fluentLayoutContent layout for text and icon placement.
ReadfluentLayout()WritesetFluentLayout()NotifyfluentLayoutChanged()QIcon iconQt icon with the same default-layout promotion as icon glyphs.
Readicon()WritesetIcon()NotifyiconChanged()bool focusVisualControls whether the focus visual frame is painted.
ReadhasFocusVisual()WritesetFocusVisual()NotifyfocusVisualChanged()InteractionState interactionStateOverrides the interaction state for guided demos or visual checks.
ReadinteractionState()WritesetInteractionState()NotifyinteractionStateChanged()bool criticalOnHoverUses the critical error color while hovered or pressed.
ReadcriticalOnHover()WritesetCriticalOnHover()NotifycriticalOnHoverChanged()QMargins cornerRadiiPer-corner radii; left/top/right/bottom map to top-left/top-right/bottom-right/bottom-left.
ReadcornerRadii()WritesetCornerRadii()ResetresetCornerRadii()NotifycornerRadiiChanged()QPoint iconOffsetPixel offset applied to iconfont drawing; positive values move right/down.
ReadiconOffset()WritesetIconOffset()qreal iconRotationClockwise rotation applied to the painted icon in degrees.
ReadiconRotation()WritesetIconRotation()qreal iconScaleUniform scale applied to the painted iconfont glyph (1.0 = no scaling). Applications can animate this property for press feedback; Button does not start a scale animation itself.
ReadiconScale()WritesetIconScale()qreal contentOpacityPainter-level opacity for the whole button (1.0 = fully opaque). Lightweight fade that avoids QGraphicsOpacityEffect's offscreen compositing overhead.
ReadcontentOpacity()WritesetContentOpacity()
Methods
ButtonStyle fluentStyle() constVisual treatment: Standard, Accent, or Subtle.
void setFluentStyle(ButtonStyle style)Visual treatment: Standard, Accent, or Subtle.
ButtonSize fluentSize() constSize preset controlling height and padding, not font.
void setFluentSize(ButtonSize size)Size preset controlling height and padding, not font.
Typography::FontRole fontRole() constFluent Typography preset used while following theme fonts.
void setFontRole(Typography::FontRole role)Fluent Typography preset used while following theme fonts.
TextColorRole textColorRole() constForeground emphasis for unfilled, unchecked buttons; filled and disabled keep contrast colors.
void setTextColorRole(TextColorRole role)Foreground emphasis for unfilled, unchecked buttons; filled and disabled keep contrast colors.
void setFont(const QFont& font)Sets an explicit font that remains unchanged by later theme refreshes.
ButtonLayout fluentLayout() constContent layout for text and icon placement.
void setFluentLayout(ButtonLayout layout)Selects an explicit layout, including TextOnly before an icon is assigned.
void setIcon(const QIcon& icon)Sets a Qt icon; the first icon uses IconBefore unless a layout was explicitly selected.
QIcon icon() constQt icon with the same default-layout promotion as icon glyphs.
bool hasFocusVisual() constControls whether the focus visual frame is painted.
void setFocusVisual(bool focus)Controls whether the focus visual frame is painted.
InteractionState interactionState() constOverrides the interaction state for guided demos or visual checks.
void setInteractionState(InteractionState state)Overrides the interaction state for guided demos or visual checks.
bool criticalOnHover() constUses the critical error color while hovered or pressed.
void setCriticalOnHover(bool enabled)Uses the critical error color while hovered or pressed.
QMargins cornerRadii() constPer-corner radii; left/top/right/bottom map to top-left/top-right/bottom-right/bottom-left.
void setCornerRadii(const QMargins& radii)Per-corner radii; left/top/right/bottom map to top-left/top-right/bottom-right/bottom-left.
void resetCornerRadii()Per-corner radii; left/top/right/bottom map to top-left/top-right/bottom-right/bottom-left.
QPoint iconOffset() constPixel offset applied to iconfont drawing; positive values move right/down.
void setIconOffset(const QPoint& offset)Pixel offset applied to iconfont drawing; positive values move right/down.
qreal iconRotation() constClockwise rotation applied to the painted icon in degrees.
void setIconRotation(qreal rotation)Clockwise rotation applied to the painted icon in degrees.
qreal iconScale() constUniform scale applied to the painted iconfont glyph (1.0 = no scaling). Applications can animate this property for press feedback; Button does not start a scale animation itself.
void setIconScale(qreal scale)Uniform scale applied to the painted iconfont glyph (1.0 = no scaling). Applications can animate this property for press feedback; Button does not start a scale animation itself.
qreal contentOpacity() constPainter-level opacity for the whole button (1.0 = fully opaque). Lightweight fade that avoids QGraphicsOpacityEffect's offscreen compositing overhead.
void setContentOpacity(qreal opacity)Painter-level opacity for the whole button (1.0 = fully opaque). Lightweight fade that avoids QGraphicsOpacityEffect's offscreen compositing overhead.
QSize sizeHint() const overrideComputes preferred size including Fluent padding, text, and iconfont content.
void setIconGlyph(const QString& glyph, int pixelSize = Typography::IconSize::Standard, const QString& family = Typography::FontFamily::FluentIcons)Sets an iconfont glyph drawn directly in paintEvent(). The first non-empty glyph switches layout to IconBefore unless setFluentLayout() was called.
Signals
void fluentStyleChanged()Visual treatment: Standard, Accent, or Subtle.
void fluentSizeChanged()Size preset controlling height and padding, not font.
void fontRoleChanged()Fluent Typography preset used while following theme fonts.
void textColorRoleChanged()Foreground emphasis for unfilled, unchecked buttons; filled and disabled keep contrast colors.
void fluentLayoutChanged()Content layout for text and icon placement.
void iconChanged()Qt icon with the same default-layout promotion as icon glyphs.
void focusVisualChanged()Controls whether the focus visual frame is painted.
void interactionStateChanged()Overrides the interaction state for guided demos or visual checks.
void criticalOnHoverChanged()Uses the critical error color while hovered or pressed.
void cornerRadiiChanged()Per-corner radii; left/top/right/bottom map to top-left/top-right/bottom-right/bottom-left.
Enumerations
enum ButtonStyleButton visual style resolved against Fluent design tokens.
StandardAccentSubtle
enum ButtonSizeButton density presets for padding and preferred height.
SmallStandardSizeLarge
enum ButtonLayoutText/icon composition mode, including centered icons above or below the label.
TextOnlyIconBeforeIconOnlyIconAfterIconAboveIconBelow
enum class TextColorRoleText and icon color emphasis level.
PrimarySecondaryAccent
enum InteractionStatePaint-state override; Rest uses the actual hover or press state.
RestHoverPressedDisabled
Protected members
Methods
void paintEvent(QPaintEvent* event) overrideCustom-paint the button instead of delegating to QStyle.
void paintButton(InteractionState state)Paints a visual state without changing the interaction-state property.
void paintButtonState(InteractionState state, bool focused)Paints an explicit focus state without moving focus; focusVisual and disabled state still apply.
virtual QRectF contentPaintRect(const QRectF& surfaceRect) constReturns the rectangle used to lay out painted icon and text content.
virtual QSize stackedContentSize() constMeasures the stacked icon and label without outer padding.
QRectF paintStackedContent(QPainter& painter, const QRectF& bounds) constPaints centered stacked content in the supplied bounds and returns the label rectangle.
QString iconGlyph() constExposes iconfont details to button subclasses.
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() constResolves the theme used by this element, honoring an inherited QWidget override.
bool effectiveThemeUsesDarkAppearance() constReturns 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() constReturns this element's authored overrides.
void clearThemeOverrides()Restores all token fields to global theme defaults.
const Colors& themeColorsRef() constNon-copying access to the active color set for hot paint paths.
Material::AcrylicToken themeAcrylic() constMaterial, elevation, and adaptive layout tokens.
QColor themeBackdrop(bool active) constWindow-chrome backdrop color for the given activation state.
virtual void onThemeUpdated()Called after the global theme changes.
Enumerations
enum ThemeGlobal visual theme used when resolving design tokens.
Light = 0Dark = 1HighContrast = 2
Types and aliases
struct ColorsDesign 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().
BindingHandle bindManaged(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction direction = PropertyBinder::OneWay, BindingOptions options = {})Installs a managed direct binding on this QWidget host.
BindingHandle bindComputed(const char* targetProp, const QVector<BindingDependency>& dependencies, std::function<QVariant()> evaluate, BindingOptions options = {})Installs an explicit-dependency C++ expression on this QWidget host.
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: QPushButton