Fluent-Qt

Dialogs & flyouts

ContentDialog

A modal dialog with title, content, and up to three commit buttons.

Example

ContentDialog: Result buttons and default command

Usage

Result buttons and default command

Primary, secondary, and close buttons update app state while the primary command is the default action.

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

auto* dialog = new ContentDialog(window());
dialog->setTitle("Save your work?");
dialog->setContent(new Label("Unsaved changes in Quarterly report will be lost unless you save them."));
dialog->setPrimaryButtonText("Save");
dialog->setSecondaryButtonText("Don't save");
dialog->setCloseButtonText("Cancel");
dialog->setDefaultButton(ContentDialog::Primary);
connect(dialog, &QDialog::finished, this, [this](int result) {
    const QString message = result == ContentDialog::Primary ? "Save selected"
        : result == ContentDialog::Secondary ? "Don't save selected" : "Cancelled";
    Toast::showOrUpdateToast(this, "gallery.action-feedback", message,
        Toast::Informational, 2200, Toast::Top, QMargins(16, 50, 16, 16));
});
connect(dialog, &QDialog::finished, dialog, &QObject::deleteLater);
dialog->open();

fluent::dialogs_flyouts::ContentDialog

Inherits Dialog

WinUI-style content dialog with title, content, and command buttons.

Constructors

Properties

QString title

Title text displayed by the surface.

Read title()Write setTitle()Notify titleChanged()
QString primaryButtonText

Text displayed by the primary command button.

Read primaryButtonText()Write setPrimaryButtonText()Notify primaryButtonTextChanged()
QString secondaryButtonText

Text displayed by the secondary command button.

Read secondaryButtonText()Write setSecondaryButtonText()Notify secondaryButtonTextChanged()
QString closeButtonText

Text displayed by the close command button.

Read closeButtonText()Write setCloseButtonText()Notify closeButtonTextChanged()
int defaultButton

Command button selected as the default action.

Read defaultButton()Write setDefaultButton()Notify defaultButtonChanged()

Methods

void setTitle(const QString& text)

Title text displayed by the surface.

void setPrimaryButtonText(const QString& text)

Text displayed by the primary command button.

QString secondaryButtonText() const

Text displayed by the secondary command button.

void setSecondaryButtonText(const QString& text)

Text displayed by the secondary command button.

QString closeButtonText() const

Text displayed by the close command button.

void setCloseButtonText(const QString& text)

Text displayed by the close command button.

int defaultButton() const

--- DefaultButton ---

void setDefaultButton(int btn)

Command button selected as the default action.

void setButtonBarHeight(int px)

--- Command bar --- Overrides the standard command-bar height (default 68px) for compact, bespoke prompts. Leave at the default to match the WinUI ContentDialog.

Signals

void titleChanged(const QString& text)

Title text displayed by the surface.

void primaryButtonTextChanged(const QString& text)

Text displayed by the primary command button.

void secondaryButtonTextChanged(const QString& text)

Text displayed by the secondary command button.

void closeButtonTextChanged(const QString& text)

Text displayed by the close command button.

void defaultButtonChanged(int btn)

Command button selected as the default action.

Enumerations

enum ContentDialogButton
  • None = 0
  • Primary
  • Secondary
  • Close

Constants

PySide6 additions

takeContent()

Detach and return the installed content to Python ownership.

Subclass interfaces

Methods

Inherited from fluent::dialogs_flyouts::Dialog

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

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