TextArea QML Type

A multi line text input control. More...

Import Statement: import QtQuick.Controls 2.0
Since: Qt 5.7



Attached Properties


Detailed Description

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.

If you want to make a TextArea scrollable, for example, when it covers an entire application page, attach it to a Flickable and combine with a ScrollBar or ScrollIndicator.

Flickable {
    id: flickable
    anchors.fill: parent

    TextArea.flickable: TextArea {
        text: "TextArea\n...\n...\n...\n...\n...\n...\n"
        wrapMode: TextArea.Wrap

    ScrollBar.vertical: ScrollBar { }

A TextArea that is attached to a Flickable does the following:

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

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.

See also Customizing TextArea.

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.

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.

placeholderText : string

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

Attached Property Documentation

TextArea.flickable : TextArea

This property attaches a text area to a Flickable.

Flickable {
    id: flickable
    anchors.fill: parent

    TextArea.flickable: TextArea {
        text: "TextArea\n...\n...\n...\n...\n...\n...\n"
        wrapMode: TextArea.Wrap

    ScrollBar.vertical: ScrollBar { }

See also ScrollBar and ScrollIndicator.

Signal Documentation

void pressAndHold(MouseEvent mouse)

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

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.