TextInput QML Type▲
-
Import Statement: import QtQuick
-
Inherits: Item
-
Group: TextInput is part of qtquick-visual, qtquick-input
Detailed Description▲
The TextInput type displays a single line of editable plain text.
TextInput is used to accept a line of text input. Input constraints can be placed on a TextInput item (for example, through a validator or inputMask), and setting echoMode to an appropriate value enables TextInput to be used for a password input field.
On macOS, the Up/Down key bindings for Home/End are explicitly disabled. If you want such bindings (on any platform), you will need to construct them in QML.
See Also▲
Property Documentation▲
horizontalAlignment : enumeration▲
verticalAlignment : enumeration
Sets the horizontal alignment of the text within the TextInput item's width and height. By default, the text alignment follows the natural alignment of the text, for example text that is read from left to right will be aligned to the left.
TextInput does not have vertical alignment, as the natural height is exactly the height of the single line of text. If you set the height manually to something larger, TextInput will always be top aligned vertically. You can use anchors to align it however you want within another item.
The valid values for horizontalAlignment are TextInput.AlignLeft, TextInput.AlignRight and TextInput.AlignHCenter.
Valid values for verticalAlignment are TextInput.AlignTop (default), TextInput.AlignBottom TextInput.AlignVCenter.
When using the attached property LayoutMirroring::enabled to mirror application layouts, the horizontal alignment of text will also be mirrored. However, the property horizontalAlignment will remain unchanged. To query the effective horizontal alignment of TextInput, use the read-only property effectiveHorizontalAlignment.
[since 5.6] bottomPadding : real▲
[since 5.6] leftPadding : real
[since 5.6] padding : real
[since 5.6] rightPadding : real
[since 5.6] topPadding : real
These properties hold the padding around the content. This space is reserved in addition to the contentWidth and contentHeight.
The individual padding properties assume the value of the padding property unless they are set explicitly. For example, if padding is set to 4 and leftPadding to 8, 8 will be used as the left padding.
If an explicit width or height is given to a TextInput, care must be taken to ensure it is large enough to accommodate the relevant padding values. For example: if topPadding and bottomPadding are set to 10, but the height of the TextInput is only set to 20, the text will not have enough vertical space in which to be rendered, and will appear clipped.
This QML property was introduced in Qt 5.6.
[read-only] acceptableInput : bool▲
This property is always true unless a validator or input mask has been set. If a validator or input mask has been set, this property will only be true if the current text is acceptable to the validator or input mask as a final string (not as an intermediate string).
activeFocusOnPress : bool▲
Whether the TextInput should gain active focus on a mouse press. By default this is set to true.
autoScroll : bool▲
Whether the TextInput should scroll when the text is longer than the width. By default this is set to true.
See Also▲
See also ensureVisible()
[read-only] canPaste : bool▲
Returns true if the TextInput is writable and the content of the clipboard is suitable for pasting into the TextInput.
[read-only] canRedo : bool▲
[read-only] canUndo : bool▲
Returns true if the TextInput is writable and there are previous operations that can be undone.
color : color▲
The text color.
[read-only] contentHeight : real▲
Returns the height of the text, including the height past the height that is covered if the text does not fit within the set height.
[read-only] contentWidth : real▲
Returns the width of the text, including the width past the width which is covered due to insufficient wrapping if wrapMode is set.
cursorDelegate : Component▲
The delegate for the cursor in the TextInput.
If you set a cursorDelegate for a TextInput, this delegate will be used for drawing the cursor instead of the standard cursor. An instance of the delegate will be created and managed by the TextInput when a cursor is needed, and the x property of the delegate instance will be set so as to be one pixel before the top left of the current character.
Note that the root item of the delegate component must be a QQuickItem or QQuickItem derived item.
cursorPosition : int▲
The position of the cursor in the TextInput. The cursor is positioned between characters.
The characters in this case refer to the string of QChar objects, therefore 16-bit Unicode characters, and the position is considered an index into this string. This does not necessarily correspond to individual graphemes in the writing system, as a single grapheme may be represented by multiple Unicode characters, such as in the case of surrogate pairs, li