Skip to main content

QCustomTextArea

QCustomTextArea

A multi-line text input.

The catalog had no multi-line input at all: QCustomInput extends QLineEdit, which is single-line by construction, so any form needing a comment, description or message body had to drop to a bare QPlainTextEdit and lose the token styling.

Built on QPlainTextEdit rather than QTextEdit: this is a plain-text control, and QPlainTextEdit's line-based layout stays fast on long input where QTextEdit's rich document does not.

Adds over the stock widget:

  • variant / sizeVariant / state, mirroring QCustomInput
  • maxLength with a live character counter
  • autoGrow, so the field grows with its content between minRows and maxRows

Emits lengthChanged(int) and limitReached(bool) alongside the inherited textChanged.

At a glance

TierFree (GPLv3)
Importfrom Custom_Widgets.QCustomTextArea import QCustomTextArea
Qt DesignerYes — drag it from the palette

Quick start

from Custom_Widgets.QCustomTextArea import QCustomTextArea

widget = QCustomTextArea()

Dark theme

Colours come from the design tokens, so the widget follows the app theme with no extra work.

QCustomTextArea in dark theme

Properties

Every property below is settable in code and in Qt Designer.

PropertyTypeDefault
frameShapeQFrame::Shape
frameShadowQFrame::Shadow
lineWidthint
midLineWidthint
frameWidthint
frameRectQRect
verticalScrollBarPolicyQt::ScrollBarPolicy
horizontalScrollBarPolicyQt::ScrollBarPolicy
sizeAdjustPolicyQAbstractScrollArea::SizeAdjustPolicy
tabChangesFocusbool
documentTitlestring
undoRedoEnabledbool
lineWrapModeQPlainTextEdit::LineWrapMode
readOnlybool
plainTextstring
overwriteModebool
tabStopDistancefloat
cursorWidthint
textInteractionFlagsQFlags<Qt::TextInteractionFlag>
blockCountint
maximumBlockCountint
backgroundVisiblebool
centerOnScrollbool
placeholderTextstring
variantenum: primary/secondary/outline/ghost``outline
sizeVariantenum: sm/md/lg``md
stateenum: default/focused/error/disabled``default
maxLengthint0
showCounterboolFalse
autoGrowboolFalse
minRowsint3
maxRowsint8
counterColorcolor
counterOverColorcolor

Signals

Signal
lengthChanged(int)
limitReached(bool)

Methods

MethodDescription
autoGrow(*args, **kwargs)Auto grow.
clearText()Clear the text.
counterColor(*args, **kwargs)Counter color.
counterOverColor(*args, **kwargs)Counter over color.
isOverLimit()Return whether the widget is over limit.
length()Length.
lengthChanged(...)Length changed.
limitReached(...)Limit reached.
maxLength(*args, **kwargs)Max length.
maxRows(*args, **kwargs)Max rows.
minRows(*args, **kwargs)Min rows.
remaining()Characters left, or -1 when no limit is set.
setError(error_text=None)Set the error.
showCounter(*args, **kwargs)Show the counter.
sizeVariant(*args, **kwargs)Size variant.
state(*args, **kwargs)State.
variant(*args, **kwargs)Variant.

Theming

Colours come from the design tokens, so they follow the active theme. Roles used: surface, on-surface, outline, focus-ring, destructive.

See Design tokens.

Runnable example

A complete app using this widget lives at examples/PySide6/QCustomTextArea/main.py.

QCustomButtonGroup · QCustomCheckBox · QCustomColorPicker · QCustomComboBox · QCustomDateEdit · QCustomDateRangePicker · QCustomEmojiPicker · QCustomFileDropZone