cf::ui::widget::material::TextField¶
Material Design 3 TextField widget. More...
#include <textfield.h>
Inherits from QLineEdit
Public Types¶
| Name | |
|---|---|
| enum class | TextFieldVariant { Filled, Outlined} TextField visual variant. |
Public Signals¶
| Name | |
|---|---|
| void | floatingChanged(bool floating) Signal emitted when floating state changes. |
Public Functions¶
| Name | |
|---|---|
| Q_ENUM(TextFieldVariant ) | |
| TextField(TextFieldVariant variant =TextFieldVariant::Filled, QWidget * parent =nullptr) Constructor with variant. |
|
| TextField(constQString & text, TextFieldVariant variant =TextFieldVariant::Filled, QWidget * parent =nullptr) Constructor with text and variant. |
|
| ~TextField() override Destructor. |
|
| TextFieldVariant | variant() const Gets the text field variant. |
| void | setVariant(TextFieldVariant variant) Sets the text field variant. |
| QString | label() const Gets the label text. |
| void | setLabel(constQString & label) Sets the label text. |
| QString | helperText() const Gets the helper text. |
| void | setHelperText(constQString & text) Sets the helper text. |
| QString | errorText() const Gets the error text. |
| void | setErrorText(constQString & text) Sets the error text. |
| bool | isFloating() const Checks if the label is in floating state. |
| QIcon | prefixIcon() const Gets the prefix icon. |
| void | setPrefixIcon(constQIcon & icon) Sets the prefix icon. |
| QIcon | suffixIcon() const Gets the suffix icon. |
| void | setSuffixIcon(constQIcon & icon) Sets the suffix icon. |
| bool | showCharacterCounter() const Gets whether character counter is shown. |
| void | setShowCharacterCounter(bool show) Sets whether character counter is shown. |
| int | maxLength() const Gets the maximum length. |
| void | setMaxLength(int length) Sets the maximum length. |
| QSize | sizeHint() const override Gets the recommended size. |
| QSize | minimumSizeHint() const override Gets the minimum recommended size. |
Protected Functions¶
| Name | |
|---|---|
| void | paintEvent(QPaintEvent * event) override Paints the text field. |
| void | resizeEvent(QResizeEvent * event) override Handles resize event. |
| void | mousePressEvent(QMouseEvent * event) override Handles mouse press event. |
| void | mouseReleaseEvent(QMouseEvent * event) override Handles mouse release event. |
| void | focusInEvent(QFocusEvent * event) override Handles focus in event. |
| void | focusOutEvent(QFocusEvent * event) override Handles focus out event. |
| void | changeEvent(QEvent * event) override Handles widget state change event. |
| void | textChanged(constQString & text) Handles text change event. |
Public Properties¶
| Name | |
|---|---|
| TextFieldVariant | variant |
| QString | label |
| QString | helperText |
| QString | errorText |
| int | maxLength |
| bool | showCharacterCounter |
| bool | isFloating |
| QIcon | prefixIcon |
| QIcon | suffixIcon |
Detailed Description¶
Material Design 3 TextField widget.
Since: 0.1
Implements Material Design 3 text field with support for filled and outlined variants. Includes floating labels, prefix/suffix icons, character counter, helper/error text, and password mode.
Public Types Documentation¶
enum TextFieldVariant¶
| Enumerator | Value | Description |
|---|---|---|
| Filled | ||
| Outlined |
TextField visual variant.
Since: 0.1
Public Signals Documentation¶
signal floatingChanged¶
Signal emitted when floating state changes.
Parameters:
- floating true if label is floating, false otherwise.
Since: 0.1
Public Functions Documentation¶
function Q_ENUM¶
function TextField¶
Constructor with variant.
Parameters:
- variant TextField visual variant.
- parent QObject parent.
Exceptions:
- None
Since: 0.1
Note: None
Warning: None
function TextField¶
explicit TextField(
constQString & text,
TextFieldVariant variant =TextFieldVariant::Filled,
QWidget * parent =nullptr
)
Constructor with text and variant.
Parameters:
- text Initial text content.
- variant TextField visual variant.
- parent QObject parent.
Exceptions:
- None
Since: 0.1
Note: None
Warning: None
function ~TextField¶
Destructor.
Exceptions:
- None
Since: 0.1
Note: None
Warning: None
function variant¶
Gets the text field variant.
Exceptions:
- None
Return: Current text field variant.
Since: 0.1
Note: None
Warning: None
function setVariant¶
Sets the text field variant.
Parameters:
- variant TextField variant to use.
Exceptions:
- None
Since: 0.1
Note: Changing variant updates the visual appearance.
Warning: None
function label¶
Gets the label text.
Exceptions:
- None
Return: Current label text.
Since: 0.1
Note: The label floats when the field has focus or content.
Warning: None
function setLabel¶
Sets the label text.
Parameters:
- label Label text to display.
Exceptions:
- None
Since: 0.1
Note: The label floats when the field has focus or content.
Warning: None
function helperText¶
Gets the helper text.
Exceptions:
- None
Return: Current helper text.
Since: 0.1
Note: Helper text is displayed below the text field.
Warning: None
function setHelperText¶
Sets the helper text.
Parameters:
- text Helper text to display.
Exceptions:
- None
Since: 0.1
Note: Helper text is displayed below the text field.
Warning: None
function errorText¶
Gets the error text.
Exceptions:
- None
Return: Current error text.
Since: 0.1
Note: Error text takes precedence over helper text.
Warning: None
function setErrorText¶
Sets the error text.
Parameters:
- text Error text to display. Empty string clears error state.
Exceptions:
- None
Since: 0.1
Note: Error text takes precedence over helper text.
Warning: None
function isFloating¶
Checks if the label is in floating state.
Exceptions:
- None
Return: true if label is floating, false otherwise.
Since: 0.1
Note: Label floats when field has focus or content.
Warning: None
function prefixIcon¶
Gets the prefix icon.
Exceptions:
- None
Return: Current prefix icon.
Since: 0.1
Note: Prefix icon is displayed at the start of the field.
Warning: None
function setPrefixIcon¶
Sets the prefix icon.
Parameters:
- icon Icon to display at the start of the field.
Exceptions:
- None
Since: 0.1
Note: Prefix icon is displayed at the start of the field.
Warning: None
function suffixIcon¶
Gets the suffix icon.
Exceptions:
- None
Return: Current suffix icon.
Since: 0.1
Note: Suffix icon is displayed at the end of the field.
Warning: None
function setSuffixIcon¶
Sets the suffix icon.
Parameters:
- icon Icon to display at the end of the field.
Exceptions:
- None
Since: 0.1
Note: Suffix icon is displayed at the end of the field.
Warning: None
function showCharacterCounter¶
Gets whether character counter is shown.
Exceptions:
- None
Return: true if character counter is visible, false otherwise.
Since: 0.1
Note: Character counter is shown in the helper text area.
Warning: None
function setShowCharacterCounter¶
Sets whether character counter is shown.
Parameters:
- show true to show character counter, false to hide.
Exceptions:
- None
Since: 0.1
Note: Character counter is shown in the helper text area.
Warning: None
function maxLength¶
Gets the maximum length.
Exceptions:
- None
Return: Maximum character length.
Since: 0.1
Note: 0 means no maximum.
Warning: None
function setMaxLength¶
Sets the maximum length.
Parameters:
- length Maximum character length. 0 means no maximum.
Exceptions:
- None
Since: 0.1
Note: 0 means no maximum.
Warning: None
function sizeHint¶
Gets the recommended size.
Exceptions:
- None
Return: Recommended size for the text field.
Since: 0.1
Note: Based on label, icons, padding, and helper text.
Warning: None
function minimumSizeHint¶
Gets the minimum recommended size.
Exceptions:
- None
Return: Minimum recommended size.
Since: 0.1
Note: Ensures touch target size requirements.
Warning: None
Protected Functions Documentation¶
function paintEvent¶
Paints the text field.
Parameters:
- event Paint event.
Exceptions:
- None
Since: 0.1
Note: Implements Material Design paint pipeline.
Warning: None
function resizeEvent¶
Handles resize event.
Parameters:
- event Resize event.
Exceptions:
- None
Since: 0.1
Note: Updates internal layout calculations.
Warning: None
function mousePressEvent¶
Handles mouse press event.
Parameters:
- event Mouse event.
Exceptions:
- None
Since: 0.1
Note: Triggers ripple effect.
Warning: None
function mouseReleaseEvent¶
Handles mouse release event.
Parameters:
- event Mouse event.
Exceptions:
- None
Since: 0.1
Note: Updates ripple state.
Warning: None
function focusInEvent¶
Handles focus in event.
Parameters:
- event Focus event.
Exceptions:
- None
Since: 0.1
Note: Updates floating label state and shows focus indicator.
Warning: None
function focusOutEvent¶
Handles focus out event.
Parameters:
- event Focus event.
Exceptions:
- None
Since: 0.1
Note: Updates floating label state and hides focus indicator.
Warning: None
function changeEvent¶
Handles widget state change event.
Parameters:
- event Change event.
Exceptions:
- None
Since: 0.1
Note: Updates appearance based on state changes.
Warning: None
function textChanged¶
Handles text change event.
Parameters:
- text New text content.
Exceptions:
- None
Since: 0.1
Note: Updates floating label state and character counter.
Warning: None
Public Property Documentation¶
property variant¶
property label¶
property helperText¶
property errorText¶
property maxLength¶
property showCharacterCounter¶
property isFloating¶
property prefixIcon¶
property suffixIcon¶
Updated on 2026-03-09 at 10:14:01 +0000