Fluent-Qt

Text fields

TextEdit

A multi-line text surface for longer-form input.

Example

TextEdit: Auto height from visible lines

Usage

Auto height from visible lines

TextEdit grows between min and max visible lines before scrolling is needed.

#include <FluentQt/TextFields.h>
using namespace fluent::textfields;

auto* textEdit = new TextEdit(this);
textEdit->setAccessibleName("Notes");
textEdit->setPlaceholderText("Type your notes here");
textEdit->setMinVisibleLines(2);
textEdit->setMaxVisibleLines(4);
textEdit->setPlainText("First line\nSecond line");

connect(textEdit, &TextEdit::textChanged,
        statusLabel, [textEdit, statusLabel] {
            statusLabel->setText(lineCountText(textEdit));
        });

fluent::textfields::TextEdit

Inherits QWidget · FluentElement · QMLPlus

Fluent multi-line text input with line-count based sizing.

Constructors

Properties

QMargins contentMargins

Minimum insets around the editable text; vertical values share the line slot and expand the control only when they overflow it.

Read contentMargins()Write setContentMargins()Notify contentMarginsChanged()
Typography::FontRole fontRole

Fluent typography role used for text rendering.

Read fontRole()Write setFontRole()Notify fontRoleChanged()
int focusedBorderWidth

Bottom border width while focused.

Read focusedBorderWidth()Write setFocusedBorderWidth()Notify focusedBorderWidthChanged()
int unfocusedBorderWidth

Bottom border width while not focused.

Read unfocusedBorderWidth()Write setUnfocusedBorderWidth()Notify unfocusedBorderWidthChanged()
int lineHeight

Visual line slot height used by the text editor.

Read lineHeight()Write setLineHeight()Notify layoutMetricsChanged()
int minVisibleLines

Minimum visible lines; raising it above the maximum raises both.

Read minVisibleLines()Write setMinVisibleLines()Notify layoutMetricsChanged()
int maxVisibleLines

Maximum visible lines; lowering it below the minimum lowers both.

Read maxVisibleLines()Write setMaxVisibleLines()Notify layoutMetricsChanged()
bool tabChangesFocus

Whether Tab advances focus instead of inserting a tab character.

Read tabChangesFocus()Write setTabChangesFocus()Notify tabChangesFocusChanged()
bool scrollChainingEnabled

Whether boundary wheel input may continue to an enclosing scroller.

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

Whether content controls the height; disable to fill a parent layout.

Read isAutoResizeEnabled()Write setAutoResizeEnabled()Notify autoResizeEnabledChanged()
bool frameVisible

Whether the editor paints an input frame and background.

Read isFrameVisible()Write setFrameVisible()Notify frameVisibleChanged()
QRect cursorRect

Current caret rectangle in this widget's coordinates, including scroll offsets.

Read cursorRect()Notify cursorRectChanged()

Methods

bool isAutoResizeEnabled() const

Whether content controls the height; disable to fill a parent layout.

void setAutoResizeEnabled(bool enabled)

Whether content controls the height; disable to fill a parent layout.

bool isFrameVisible() const

Whether the editor paints an input frame and background.

void setFrameVisible(bool visible)

Whether the editor paints an input frame and background.

QTextCursor textCursor() const

Returns the current editing cursor, including its selection.

QRect cursorRect() const

Current caret rectangle in this widget's coordinates, including scroll offsets.

void setTextCursor(const QTextCursor& cursor)

Sets a cursor belonging to this editor's document.

void appendPlainText(const QString& text)

Appends a plain-text paragraph, including when the editor is read-only.

QMargins contentMargins() const

Minimum insets around the editable text; vertical values share the line slot and expand the control only when they overflow it.

void setContentMargins(const QMargins& margins)

Minimum insets around the editable text; vertical values share the line slot and expand the control only when they overflow it.

Typography::FontRole fontRole() const

Fluent typography role used for text rendering.

void setFontRole(Typography::FontRole role)

Fluent typography role used for text rendering.

int focusedBorderWidth() const

Bottom border width while focused.

void setFocusedBorderWidth(int width)

Bottom border width while focused.

int unfocusedBorderWidth() const

Bottom border width while not focused.

void setUnfocusedBorderWidth(int width)

Bottom border width while not focused.

int lineHeight() const

Visual line slot height used by the text editor.

void setLineHeight(int height)

Visual line slot height used by the text editor.

int minVisibleLines() const

Minimum visible lines; raising it above the maximum raises both.

void setMinVisibleLines(int lines)

Minimum visible lines; raising it above the maximum raises both.

int maxVisibleLines() const

Maximum visible lines; lowering it below the minimum lowers both.

void setMaxVisibleLines(int lines)

Maximum visible lines; lowering it below the minimum lowers both.

bool tabChangesFocus() const

Whether Tab advances focus instead of inserting a tab character.

void setTabChangesFocus(bool enabled)

Whether Tab advances focus instead of inserting a tab character.

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.

Signals

void autoResizeEnabledChanged()

Whether content controls the height; disable to fill a parent layout.

void frameVisibleChanged()

Whether the editor paints an input frame and background.

void cursorRectChanged()

Emitted after the caret's effective geometry changes; updates are coalesced.

void contentMarginsChanged()

Minimum insets around the editable text; vertical values share the line slot and expand the control only when they overflow it.

void fontRoleChanged()

Fluent typography role used for text rendering.

void focusedBorderWidthChanged()

Bottom border width while focused.

void unfocusedBorderWidthChanged()

Bottom border width while not focused.

void layoutMetricsChanged()

Visual line slot height used by the text editor.

void tabChangesFocusChanged()

Whether Tab advances focus instead of inserting a tab character.

void scrollChainingEnabledChanged()

Whether boundary wheel input may continue to an enclosing scroller.

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