Text fields
LineEdit
A single-line text box with Fluent styling and a clear button.
Example

Usage
Units and inline actions
Keep the value easy to read, with its context close at hand.
#include <FluentQt/TextFields.h>
using namespace fluent::textfields;
auto* width = new LineEdit(this);
width->setAccessibleName("Canvas width");
width->setText("1280");
width->setTrailingText("px");
width->setClearButtonAccessibleName("Clear canvas width");
width->setClearButtonFocusPolicy(Qt::StrongFocus);
auto* name = new LineEdit(this);
name->setAccessibleName("Export name");
name->setText("gallery-preview-v2");
name->setClearButtonEnabled(false);
auto* reset = new Button("Reset");
reset->setFluentStyle(Button::Subtle);
reset->setFluentSize(Button::Small);
reset->setFontRole(Typography::FontRole::Caption);
auto actionFont = reset->font();
actionFont.setStyleName(QString());
actionFont.setWeight(QFont::DemiBold);
reset->setFont(actionFont);
reset->setTextColorRole(Button::TextColorRole::Accent);
reset->setFixedSize(Spacing::XXLarge, Spacing::ControlHeight::Small);
reset->setFocusVisual(true);
reset->setAccessibleName("Reset export name");
name->setTrailingWidget(reset, WidgetOwnership::Owned);
connect(reset, &Button::clicked, name, [name] {
name->setText("gallery-preview");
});import fluentqt
from PySide6.QtCore import Qt
from PySide6.QtGui import QFont
width_column = root.add_column()
name_column = root.add_column()
width = fluentqt.LineEdit(width_column)
width.setAccessibleName('Canvas width')
width.setText('1280')
width.setTrailingText('px')
width.setClearButtonAccessibleName('Clear canvas width')
width.setClearButtonFocusPolicy(Qt.StrongFocus)
name = fluentqt.LineEdit(name_column)
name.setAccessibleName('Export name')
name.setText('gallery-preview-v2')
name.setClearButtonEnabled(False)
reset = fluentqt.Button('Reset')
reset.setFluentStyle(fluentqt.Button.ButtonStyle.Subtle)
reset.setFluentSize(fluentqt.Button.ButtonSize.Small)
reset.setFontRole(fluentqt.FontRole.Caption)
action_font = reset.font()
action_font.setStyleName('')
action_font.setWeight(QFont.DemiBold)
reset.setFont(action_font)
reset.setTextColorRole(fluentqt.Button.TextColorRole.Accent)
reset.setFixedSize(fluentqt.Spacing.XXLarge, fluentqt.Spacing.ControlHeight.Small)
reset.setFocusVisual(True)
reset.setAccessibleName('Reset export name')
name.setTrailingWidget(reset, fluentqt.WidgetOwnership.Owned)
reset.clicked.connect(lambda: name.setText('gallery-preview'))API
DeclarationNo matching API members.
fluent::textfields::LineEdit
Inherits QLineEdit · FluentElement · QMLPlus
Fluent single-line text input with clear button and focus underline.
Constructors
Properties
QMargins contentMarginsContent margins whose horizontal values include Qt's internal text inset.
ReadcontentMargins()WritesetContentMargins()NotifycontentMarginsChanged()Typography::FontRole fontRoleFluent typography role used for text rendering.
ReadfontRole()WritesetFontRole()NotifyfontRoleChanged()bool clearButtonEnabledWhether the trailing clear button is enabled.
ReadisClearButtonEnabled()WritesetClearButtonEnabled()NotifyclearButtonEnabledChanged()int clearButtonSizeSize of the clear button, defaulting to 24 logical pixels.
ReadclearButtonSize()WritesetClearButtonSize()NotifyclearButtonSizeChanged()QPoint clearButtonOffsetPixel offset applied to the clear button.
ReadclearButtonOffset()WritesetClearButtonOffset()NotifyclearButtonOffsetChanged()int focusedBorderWidthBottom border width while focused.
ReadfocusedBorderWidth()WritesetFocusedBorderWidth()NotifyfocusedBorderWidthChanged()int unfocusedBorderWidthBottom border width while not focused.
ReadunfocusedBorderWidth()WritesetUnfocusedBorderWidth()NotifyunfocusedBorderWidthChanged()bool frameVisibleWhether LineEdit paints its input frame and focus underline.
ReadisFrameVisible()WritesetFrameVisible()NotifyframeVisibleChanged()QString trailingText- Read
trailingText()WritesetTrailingText()NotifytrailingTextChanged() QWidget* trailingWidget- Read
trailingWidget()NotifytrailingWidgetChanged() fluent::WidgetOwnership trailingWidgetOwnership- Read
trailingWidgetOwnership()NotifytrailingWidgetOwnershipChanged() QString clearButtonAccessibleName- Read
clearButtonAccessibleName()WritesetClearButtonAccessibleName()NotifyclearButtonAccessibleNameChanged() Qt::FocusPolicy clearButtonFocusPolicy- Read
clearButtonFocusPolicy()WritesetClearButtonFocusPolicy()NotifyclearButtonFocusPolicyChanged()
Methods
QMargins contentMargins() constContent margins whose horizontal values include Qt's internal text inset.
void setContentMargins(const QMargins& margins)Content margins whose horizontal values include Qt's internal text inset.
Typography::FontRole fontRole() constFluent typography role used for text rendering.
void setFontRole(Typography::FontRole role)Fluent typography role used for text rendering.
bool isClearButtonEnabled() constWhether the trailing clear button is enabled.
void setClearButtonEnabled(bool enabled)Whether the trailing clear button is enabled.
int clearButtonSize() constSize of the clear button, defaulting to 24 logical pixels.
void setClearButtonSize(int size)Size of the clear button, defaulting to 24 logical pixels.
QPoint clearButtonOffset() constPixel offset applied to the clear button.
void setClearButtonOffset(const QPoint& offset)Pixel offset applied to the clear button.
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.
bool isFrameVisible() constWhether LineEdit paints its input frame and focus underline.
void setFrameVisible(bool visible)Whether LineEdit paints its input frame and focus underline.
void setTrailingText(const QString& text)Displays a plain-text suffix without changing the editable value; replaces hosted content.
bool setTrailingWidget(QWidget* widget, WidgetOwnership ownership)Hosts one trailing widget using explicit ownership; rejects the host and its ancestors.
QWidget* takeTrailingWidget()Detaches the custom trailing widget and transfers it to the caller.
void releaseTrailingWidget()Releases custom trailing content according to its recorded ownership policy.
Signals
void contentMarginsChanged()Content margins whose horizontal values include Qt's internal text inset.
void fontRoleChanged()Fluent typography role used for text rendering.
void clearButtonEnabledChanged()Whether the trailing clear button is enabled.
void clearButtonSizeChanged()Size of the clear button, defaulting to 24 logical pixels.
void clearButtonOffsetChanged()Pixel offset applied to the clear button.
void focusedBorderWidthChanged()Bottom border width while focused.
void unfocusedBorderWidthChanged()Bottom border width while not focused.
void frameVisibleChanged()Whether LineEdit paints its input frame and focus underline.
Destructors
Subclass interfaces
Methods
virtual void paintFrame(QPainter& painter)Paints the input surface when frameVisible is enabled.
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:QLineEdit