Text fields
TextEdit
A multi-line text surface for longer-form input.
Example

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));
});import fluentqt
text_edit = fluentqt.TextEdit()
text_edit.setAccessibleName('Notes')
text_edit.setPlaceholderText('Type your notes here')
text_edit.setMinVisibleLines(2)
text_edit.setMaxVisibleLines(4)
text_edit.setPlainText('First line\nSecond line')
def line_count_text():
count = max(1, text_edit.toPlainText().count("\n") + 1)
return (
f"Lines: {count}, visible range: "
f"{text_edit.minVisibleLines()}-{text_edit.maxVisibleLines()}"
)
text_edit.textChanged.connect(lambda: status.setText(line_count_text()))API
DeclarationNo matching API members.
fluent::textfields::TextEdit
Inherits QWidget · FluentElement · QMLPlus
Fluent multi-line text input with line-count based sizing.
Constructors
Properties
QMargins contentMarginsMinimum insets around the editable text; vertical values share the line slot and expand the control only when they overflow it.
ReadcontentMargins()WritesetContentMargins()NotifycontentMarginsChanged()Typography::FontRole fontRoleFluent typography role used for text rendering.
ReadfontRole()WritesetFontRole()NotifyfontRoleChanged()int focusedBorderWidthBottom border width while focused.
ReadfocusedBorderWidth()WritesetFocusedBorderWidth()NotifyfocusedBorderWidthChanged()int unfocusedBorderWidthBottom border width while not focused.
ReadunfocusedBorderWidth()WritesetUnfocusedBorderWidth()NotifyunfocusedBorderWidthChanged()int lineHeightVisual line slot height used by the text editor.
ReadlineHeight()WritesetLineHeight()NotifylayoutMetricsChanged()int minVisibleLinesMinimum visible lines; raising it above the maximum raises both.
ReadminVisibleLines()WritesetMinVisibleLines()NotifylayoutMetricsChanged()int maxVisibleLinesMaximum visible lines; lowering it below the minimum lowers both.
ReadmaxVisibleLines()WritesetMaxVisibleLines()NotifylayoutMetricsChanged()bool tabChangesFocusWhether Tab advances focus instead of inserting a tab character.
ReadtabChangesFocus()WritesetTabChangesFocus()NotifytabChangesFocusChanged()bool scrollChainingEnabledWhether boundary wheel input may continue to an enclosing scroller.
ReadisScrollChainingEnabled()WritesetScrollChainingEnabled()NotifyscrollChainingEnabledChanged()bool autoResizeEnabledWhether content controls the height; disable to fill a parent layout.
ReadisAutoResizeEnabled()WritesetAutoResizeEnabled()NotifyautoResizeEnabledChanged()bool frameVisibleWhether the editor paints an input frame and background.
ReadisFrameVisible()WritesetFrameVisible()NotifyframeVisibleChanged()QRect cursorRectCurrent caret rectangle in this widget's coordinates, including scroll offsets.
ReadcursorRect()NotifycursorRectChanged()
Methods
bool isAutoResizeEnabled() constWhether 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() constWhether the editor paints an input frame and background.
void setFrameVisible(bool visible)Whether the editor paints an input frame and background.
QTextCursor textCursor() constReturns the current editing cursor, including its selection.
QRect cursorRect() constCurrent 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 setPlainText(const QString& text)Text APIs.
void appendPlainText(const QString& text)Appends a plain-text paragraph, including when the editor is read-only.
QMargins contentMargins() constMinimum 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() constFluent typography role used for text rendering.
void setFontRole(Typography::FontRole role)Fluent typography role used for text rendering.
int focusedBorderWidth() constBottom border width while focused.
void setFocusedBorderWidth(int width)Bottom border width while focused.
int unfocusedBorderWidth() constBottom border width while not focused.
void setUnfocusedBorderWidth(int width)Bottom border width while not focused.
int lineHeight() constVisual line slot height used by the text editor.
void setLineHeight(int height)Visual line slot height used by the text editor.
int minVisibleLines() constMinimum 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() constMaximum 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() constWhether 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() constWhether 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() 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)Component-facing token accessors.
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 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 bind(const char* targetProp, QObject* source, const char* sourceProp, PropertyBinder::Direction dir = PropertyBinder::OneWay)Binds a source property to a property on the QWidget host.
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 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