Provides a component for editing and displaying both plain and rich text. More...
The TextArea component displays a block of editable and formatted text. It can display both plain and rich text. TextArea implements the horizontal and vertical scrolling. Scroll bars appear when the content is flicked, or on the focus gain if the content does not fit to view port. TextArea is a superset of TextEdit to implement the Symbian-style look-and-feel. The clipboard support is provided by the cut(), copy(), and paste() functions.
Note: Copy and paste functionality between a Qt Quick Components application and native Symbian application does not work. For more information, see QTBUG-5701.
| Code | Appearance |
|---|---|
TextArea { height: 70; width: 160 } |
|
TextArea { height: 70; width: 160 placeholderText: "Enter Text Here" } |
|
TextArea { height: 70; width: 160 text: "TextArea" } |
|
TextArea { height: 70; width: 160 text: "TextArea" focus: true } |
|
TextArea { height: 70; width: 160 text: "Text Area Text Area Text Area Text Area Text Area Text Area." } |
Appearance while draging. See the Touch Interaction section. |
TextArea { height: 70; width: 160 text: "TextArea" readOnly: true } |
|
TextArea { height: 70; width: 160 text: "TextArea" enabled: false } |
|
TextArea { height: 70; width: 160 text: "TextArea" errorHighlight: true } |
|
| Selected Text | Adjust Selection |
|---|---|
|
|
| Place Cursor | Paste Menu |
|---|---|
|
|
Different actions trigger different responses during certain conditions. Touch actions trigger different responses than keyboard actions. Further, responses depend on whether the TextArea is marked as readOnly.
This table summarizes the Symbian TextArea behaviors for editable text for touch interaction.
| Action | On Text | On the Cursor / Cursor Handle | On Selected Text | On Selection Handle |
|---|---|---|---|---|
| Tap | Places the cursor, and opens virtual keyboard. | Opens virtual keyboard. | Deselects the current selection, places the cursor, and opens virtual keyboard. | Deselects the current selection, places the cursor at the touched position, and opens virtual keyboard. |
| Double-tap | Selects the word, displays the selection handles on both sides, and shows the context menu (Copy / Cut / Paste). | Selects the word, displays the selection handles on both sides, and shows the context menu (Copy / Cut / Paste). | Selects the word, displays the selection handles on both sides, and shows the context menu (Copy / Cut / Paste). | Selects the word, displays the selection handles on both sides, and shows the context menu (Copy / Cut / Paste). |
| Triple-tap | Selects all and shows the context menu (Copy / Cut / Paste). | Selects all and shows the context menu (Copy / Cut / Paste). | Selects all and shows the context menu (Copy / Cut / Paste). | Selects all and shows the context menu (Copy / Cut / Paste). |
| Tap and Hold | Places the cursor and displays the magnifier. | Displays the magnifier. | Deselects the current selection, dismisses the context menu, places the cursor to the touched point, and displays the magnifier. | Dismisses the context menu and displays the magnifier |
| Release After Tap and Hold | Shows the context menu (Paste). | Dismisses the magnifier and shows the context menu (Paste). | Shows the context menu (Paste). | Dismisses the magnifier and shows the context menu (Copy / Cut / Paste). |
| Drag | Pans the text. | Moves the cursor, with the magnifier displayed above. | Pans the text. | Dismisses the context menu and changes the selection character-by-character, with the magnifier displayed above. |
| Release After Drag | - | Dismisses the magnifier and shows the context menu (Paste). | - | Dismisses the magnifier and shows the context menu (Copy / Cut / Paste). |
This table summarizes the Symbian TextArea behaviors for non-editable text for touch interaction.
| Action | On Text | On Selected Text | On Selection Handle |
|---|---|---|---|
| Tap | - | Deselects the current selection. | Deselects the current selection. |
| Double-tap | Selects the word, displays the selection handles on both sides and shows the context menu (Copy). | Selects the word, displays the selection handles on both sides and shows the context menu (Copy). | Selects the word, displays the selection handles on both sides and shows the context menu (Copy). |
| Triple-tap | Selects all and shows the context menu (Copy). | Selects all and shows the context menu (Copy). | Selects all and shows the context menu (Copy). |
| Tap and Hold | - | Deselects the current selection. | Dismisses the context menu and displays the magnifier. |
| Release After Tap and Hold | - | - | Dismisses the magnifier and shows the context menu (Copy). |
| Drag | Pans the text. | Pans the text and hides the context menu. | Dismisses the context menu and changes the selection character -by-character, with the magnifier displayed above. |
| Release After Drag | - | Shows the context menu (Copy). | Dismisses the magnifier and shows the context menu (Copy). |
This table summarizes the Symbian TextArea behaviors for editable text for keyboard interaction.
| Keypresses | Action |
|---|---|
| Backspace | Deletes the character to the left of the cursor. |
| Left | Moves the cursor one character to the left. |
| Right | Moves the cursor one character to the right. |
| Up | Moves the cursor one line up. |
| Down | Moves the cursor one line down. |
| Shift+Left | Select the character to the left. |
| Shift+Right | Select the character to the right. |
| Shift+Ctrl+Left | Select the word to the left. |
| Shift+Ctrl+Right | Select the word to the right. |
| Shift+Up | Select the characters to the one line up. |
| Shift+Down | Select the characters to the one line down. |
Note: Currently, copy-paste-cut shortcuts don't work on Symbian see QTBUG-5730
This table summarizes the Symbian TextArea behaviors for editable text for keyboard interaction.
| Keypresses | Action |
|---|---|
| Left | Moves the cursor one character to the left. |
| Right | Moves the cursor one character to the right. |
| Up | Moves the cursor one line up. |
| Down | Moves the cursor one line down. |
| Shift+Left | Select the character to the left. |
| Shift+Right | Select the character to the right. |
| Shift+Ctrl+Left | Select the word to the left. |
| Shift+Ctrl+Right | Select the word to the right. |
| Shift+Up | Select the characters to the one line up. |
| Shift+Down | Select the characters to the one line down. |
The text area resizes implicitly to accommodate more text. The maximum sizes are set with the platformMaxImplicitHeight and platformMaxImplicitWidth properties.
| Description | Minimum Size |
|---|---|
| Minimum implicit size for TextArea is 20 * " " on current font. |
|
| If there is placeholderText defined it's length is the text's minimum implicit size. |
|
| Description | Growth pattern |
|---|---|
With default values TextArea grows indefinitely to right.TextArea { text: "TextArea TextArea TextArea TextArea" } |
|
Setting platformMaxImplicitWidth defines a wrapping point. When that width is reached TextArea grows indefinitely to bottom.TextArea { platformMaxImplicitWidth: 200 text: "TextArea TextArea TextArea TextArea TextArea TextArea TextArea" } |
|
Setting platformMaxImplicitHeight and platformMaxImplicitWidth restricts TextArea to grow only to those values.TextArea { platformMaxImplicitHeight: 70 platformMaxImplicitWidth: 200 text: "TextArea TextArea TextArea TextArea TextArea TextArea TextArea" } |
|
read-onlycursorPosition : int |
The position of the cursor in the TextArea.
See also TextEdit::cursorPosition.
read-onlyfont : font |
Font information for the text in the text field.
See also TextEdit::font.
Sets the horizontal and vertical alignment of the text within the TextArea item's width and height. By default, the text is top-left aligned.
For details of the options, see: TextEdit::horizontalAlignment
read-onlyinputMethodHints : int |
Settings that indicate what kind of input can be accepted by the textarea. The value is from Qt::InputMethodHints.
See also TextEdit::inputMethodHints.
read-onlyplaceholderText : string |
The text that is shown in the text area before the user enters any text. When the user starts entering text, the placeholder text is hidden.
read-onlyplatformMaxImplicitHeight : double |
Defines the maximum height that the TextArea can grow.
The default value for this property is -1 and the height is allowed to grow infinitely.
If a height is explicitly set then this property has no effect.
See also platformMaxImplicitWidth.
read-onlyplatformMaxImplicitWidth : double |
Defines the maximum width that the TextArea can grow.
The default value for this property is -1, which allows the widthto grow infinitely.
If a width is explicitly set then this property has no effect.
See also platformMaxImplicitHeight.
read-onlyreadOnly : bool |
If true, the text field can only be viewed and cannot be edited.
If this is false, the text field can be edited.
See also TextEdit::readOnly.
read-onlyselectedText : string |
This read-only property provides the text that is currently selected in the text field.
See also TextEdit::selectedText.
read-onlyselectionEnd : int |
The cursor position after the last character in the current selection.
See also selectionstart, selectedText, cursorPosition, and TextEdit::selectionEnd.
read-onlyselectionStart : int |
The cursor position before the first character in the current selection.
See also selectionEnd, selectedText, cursorPosition, and TextEdit::selectionStart.
read-onlytext : string |
The text that has been entered into the text field.
read-onlytextFormat : int |
This determines if the text is displayed as rich text or plain text. By default it will and determine if the text is rich text or plain text and display it appropriately.
See TextEdit::textFormat for the enumeration details.
read-onlywrapMode : int |
This determines if text in the TextArea is wrapped or not.
See TextEdit::wrapMode for details of the different modes.
Moves the currently selected text to the system clipboard.
See also TextEdit::cut().
Returns the character position at x pixels from the left edge of the text field and y pixels from the top edge of the text field.
See also TextEdit::positionAt().
Returns the rectangle that the cursor would occupy if it was placed at pos character position.
This is similar to setting the cursorPosition and then querying the cursor rectangle, but the cursorPosition is not changed.
See also cursorPosition and TextEdit::positionToRectangle().
Causes the text from start to end to be selected.
See also selectionStart, selectionEnd, and TextEdit::select().
Causes all text in the text field to be selected.
See also TextEdit::selectAll().
Causes the word closest to the current cursor position to be selected.
See also TextEdit::selectWord().