TextArea QML Type

  • Import Statement: import QtQuick.Controls

  • Inherits: TextEdit

  • Group: TextArea is part of qtquickcontrols-input

Detailed Description

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

Image non disponible
 
Sélectionnez
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.

Image non disponible
 
Sélectionnez
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:

 
Sélectionnez
TextField {
    id: textField
}

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

See Also

Property Documentation

 

background : Item

This property holds the background item.

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 o