TextArea QML Type

Multi-line text input area. More...

Properties

Attached Properties

Signals

Detailed Description

\inheritsTextEdit \inqmlmodule QtQuick.Controls \since 5.7 \ingroup qtquickcontrols-input

TextArea is a multi-line text editor. TextArea extends TextEdit with a placeholder text functionality, and adds decoration.

 TextArea {
     placeholderText: qsTr("Enter description")
 }

TextArea is not scrollable by itself. Especially on screen-size constrained platforms, it is often preferable to make entire application pages scrollable. On such a scrollable page, a non-scrollable TextArea might behave better than nested scrollable controls. Notice, however, that in such a scenario, the background decoration of the TextArea scrolls together with the rest of the scrollable content.

Scrollable TextArea

If you want to make a TextArea scrollable, for example, when it covers an entire application page, it can be placed inside a ScrollView.

 ScrollView {
     id: view
     anchors.fill: parent

     TextArea {
         text: "TextArea\n...\n...\n...\n...\n...\n...\n"
     }
 }

A TextArea that is placed inside a ScrollView does the following:

  • Sets the content size automatically
  • Ensures that the background decoration stays in place
  • Clips the content

Tab Focus

By default, pressing the tab key while TextArea has active focus results in a tab character being input into the control itself. To make tab pass active focus onto another item, use the attached KeyNavigation properties:

 TextField {
     id: textField
 }

 TextArea {
     KeyNavigation.priority: KeyNavigation.BeforeItem
     KeyNavigation.tab: textField
 }

See also TextField, Customizing TextArea, and Input Controls.

Property Documentation

background : Item

This property holds the background item.

Note: If the background item has no explicit size specified, it automatically follows the control's size. In most cases, there is no need to specify width or height for a background item.

Note: Most controls use the implicit size of the background item to calculate the implicit size of the control itself. If you replace the background item with a custom one, you should also consider providing a sensible implicit size for it (unless it is an item like Image which has its own implicit size).

See also Customizing TextArea.


bottomInset : real

\sinceQtQuick.Controls 2.5 (Qt 5.12)

This property holds the bottom inset for the background.

See also Control Layout and topInset.


focusReason : enumeration

This property holds the reason of the last focus change.

Note: This property does not indicate whether the control has active focus, but the reason why the control either gained or lost focus.

ConstantDescription
Qt.MouseFocusReasonA mouse action occurred.
Qt.TabFocusReasonThe Tab key was pressed.
Qt.BacktabFocusReasonA Backtab occurred. The input for this may include the Shift or Control keys; e.g. Shift+Tab.
Qt.ActiveWindowFocusReasonThe window system made this window either active or inactive.
Qt.PopupFocusReasonThe application opened/closed a pop-up that grabbed/released the keyboard focus.
Qt.ShortcutFocusReasonThe user typed a label's buddy shortcut
Qt.MenuBarFocusReasonThe menu bar took focus.
Qt.OtherFocusReasonAnother reason, usually application-specific.

See also Item::activeFocus.


hoverEnabled : bool

\sinceQtQuick.Controls 2.1 (Qt 5.8)

This property determines whether the text area accepts hover events. The default value is true.

See also hovered.


hovered : bool

\sinceQtQuick.Controls 2.1 (Qt 5.8) \readonly

This property holds whether the text area is hovered.

See also hoverEnabled.


implicitBackgroundHeight : real

\sinceQtQuick.Controls 2.5 (Qt 5.12) \readonly

This property holds the implicit background height.

The value is equal to background ? background.implicitHeight : 0.

See also implicitBackgroundWidth.


implicitBackgroundWidth : real

\sinceQtQuick.Controls 2.5 (Qt 5.12) \readonly

This property holds the implicit background width.

The value is equal to background ? background.implicitWidth : 0.

See also implicitBackgroundHeight.


leftInset : real

\sinceQtQuick.Controls 2.5 (Qt 5.12)

This property holds the left inset for the background.

See also Control Layout and rightInset.


placeholderText : string

This property holds the short hint that is displayed in the text area before the user enters a value.


placeholderTextColor : color

\sinceQtQuick.Controls 2.5 (Qt 5.12)

This property holds the color of placeholderText.

See also placeholderText.


rightInset : real

\sinceQtQuick.Controls 2.5 (Qt 5.12)

This property holds the right inset for the background.

See also Control Layout and leftInset.


topInset : real

\sinceQtQuick.Controls 2.5 (Qt 5.12)

This property holds the top inset for the background.

See also Control Layout and bottomInset.


Attached Property Documentation

TextArea.flickable : TextArea

This property attaches a text area to a Flickable.

See also ScrollBar, ScrollIndicator, and Scrollable TextArea.


Signal Documentation

pressAndHold(MouseEvent event)

This signal is emitted when there is a long press (the delay depends on the platform plugin). The event parameter provides information about the press, including the x and y coordinates of the press, and which button is pressed.

Note: The corresponding handler is onPressAndHold.

See also pressed and released.


pressed(MouseEvent event)

\sinceQtQuick.Controls 2.1 (Qt 5.8)

This signal is emitted when the text area is pressed by the user. The event parameter provides information about the press, including the x and y coordinates of the press, and which button is pressed.

Note: The corresponding handler is onPressed.

See also released and pressAndHold.


released(MouseEvent event)

\sinceQtQuick.Controls 2.1 (Qt 5.8)

This signal is emitted when the text area is released by the user. The event parameter provides information about the release, including the x and y coordinates of the press, and which button is pressed.

Note: The corresponding handler is onReleased.

See also pressed and pressAndHold.