Fluent-Qt

Dialogs & flyouts

Dialog

A modal window surface that hosts arbitrary content above the app.

Example

Dialog: Rename a project

Usage

Rename a project

Edit a project name, then apply the change or cancel to keep the original.

#include <FluentQt/DialogsFlyouts.h>
using namespace fluent::dialogs_flyouts;

auto* root = new QWidget(this);
auto* layout = new QVBoxLayout(root);
auto* open = new Button(QStringLiteral("Rename project"), root);
open->setFluentStyle(Button::Accent);
auto* status = new Label(QStringLiteral("Project name: Northwind Analytics"), root);
layout->addWidget(open, 0, Qt::AlignLeft);
layout->addWidget(status);
QObject::connect(open, &Button::clicked, root, [open, status] {
    auto* dialog = new Dialog(open->window());
    dialog->setThemeSource(open);
    dialog->setMinimumSize(480, 280);
    auto* content = new QVBoxLayout(dialog);
    content->setContentsMargins(32, 28, 32, 28);
    content->setSpacing(14);
    auto* title = new Label(QStringLiteral("Rename project"), dialog);
    title->setFluentTypography(Typography::FontRole::Subtitle);
    content->addWidget(title);
    auto* name = new LineEdit(dialog);
    name->setAccessibleName(QStringLiteral("Project name"));
    name->setText(status->text().replace(QStringLiteral("Project name: "), QString()));
    content->addWidget(name);
    content->addStretch();
    auto* commands = new QHBoxLayout;
    auto* cancel = new Button(QStringLiteral("Cancel"), dialog);
    auto* apply = new Button(QStringLiteral("Apply"), dialog);
    apply->setFluentStyle(Button::Accent);
    commands->addStretch();
    commands->addWidget(cancel);
    commands->addWidget(apply);
    content->addLayout(commands);
    QObject::connect(cancel, &Button::clicked, dialog, &QDialog::reject);
    QObject::connect(apply, &Button::clicked, dialog, &QDialog::accept);
    QObject::connect(dialog, &QDialog::accepted, status, [status, name] {
        status->setText(QStringLiteral("Project name: %1").arg(name->text()));
    });
    QObject::connect(dialog, &QDialog::finished, dialog, &QObject::deleteLater);
    dialog->open();
});
return root;

fluent::dialogs_flyouts::Dialog

Inherits QDialog · FluentElement · QMLPlus

Same-window Fluent dialog shell with optional smoke scrim and enter/exit fade.

Constructors

Properties

bool isOpen

Logical requested open state, not animation-complete or QWidget visibility.

Read isOpen()Write setIsOpen()Notify isOpenChanged()
double animationProgress
Read animationProgress()Write setAnimationProgress()
bool dragEnabled
Read isDragEnabled()Write setDragEnabled()Notify dragEnabledChanged()
bool animationEnabled
Read isAnimationEnabled()Write setAnimationEnabled()Notify animationEnabledChanged()
bool smokeEnabled

Historical smoke bundle; enabled only while modal and dim are both on.

Read isSmokeEnabled()Write setSmokeEnabled()Notify smokeEnabledChanged()
bool modal
Read isModal()Write setModal()Notify modalChanged()
bool dim
Read isDim()Write setDim()Notify dimChanged()
double dimOpacity

Scrim opacity in [0, 1]; -1 uses the theme smoke token when dim is enabled.

Read dimOpacity()Write setDimOpacity()Notify dimOpacityChanged()
double backdropBlurRadius

Cached owning-window blur radius in logical pixels [0, 32]; 0 disables blur.

Read backdropBlurRadius()Write setBackdropBlurRadius()Notify backdropBlurRadiusChanged()
ClosePolicy closePolicy
Read closePolicy()Write setClosePolicy()Notify closePolicyChanged()

Methods

bool isOpen() const

Logical requested open state, not animation-complete or QWidget visibility.

void setSmokeEnabled(bool enabled)

Historical smoke bundle; enabled only while modal and dim are both on.

bool isSmokeEnabled() const

Historical smoke bundle; enabled only while modal and dim are both on.

double dimOpacity() const

Scrim opacity in [0, 1]; -1 uses the theme smoke token when dim is enabled.

void setDimOpacity(double opacity)

Scrim opacity in [0, 1]; -1 uses the theme smoke token when dim is enabled.

double backdropBlurRadius() const

Cached owning-window blur radius in logical pixels [0, 32]; 0 disables blur.

void setBackdropBlurRadius(double radius)

Cached owning-window blur radius in logical pixels [0, 32]; 0 disables blur.

void refreshBackdrop()

Recaptures the owning-window content after background changes.

void setThemeSource(QWidget* source)

Uses a widget as the local theme source while the dialog is shown.

void setIsOpen(bool open)

Logical requested open state, not animation-complete or QWidget visibility.

Signals

void isOpenChanged(bool open)

Logical requested open state, not animation-complete or QWidget visibility.

void opening()

Opening transition started. Compatibility alias: aboutToShow().

void closing()

Closing transition started. Compatibility alias: aboutToHide().

void smokeEnabledChanged(bool enabled)

Historical smoke bundle; enabled only while modal and dim are both on.

void dimOpacityChanged(double opacity)

Scrim opacity in [0, 1]; -1 uses the theme smoke token when dim is enabled.

void backdropBlurRadiusChanged(double radius)

Cached owning-window blur radius in logical pixels [0, 32]; 0 disables blur.

Enumerations

enum CloseFlag

Overlay light-dismiss flags; same bits as Popup::CloseFlag.

  • NoAutoClose = 0
  • CloseOnPressOutside = 1 << 0
  • CloseOnEscape = 1 << 1

Types and aliases

Destructors

Subclass interfaces

Methods

QWidget* ownerWidget() const

Owning top-level used for centering, theme inheritance, and the smoke scrim.

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