TextField QML Type

Single-line text input field. More...

Import Statement: import QtQuick.Controls 2.14
Since: Qt 5.7
Inherits:

TextInput

Properties

Signals

Detailed Description

TextField is a single line text editor. TextField extends TextInput with a placeholder text functionality, and adds decoration.

A text field in its normal state.

A text field that has active focus.

A text field that is disabled.
TextField {
    placeholderText: qsTr("Enter name")
}

See also TextArea, Customizing TextField, 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 TextField.


bottomInset : real

This property holds the bottom inset for the background.

This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).

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

This property determines whether the text field accepts hover events. The default value is false.

This property was introduced in QtQuick.Controls 2.1 (Qt 5.8).

See also hovered.


[read-only] hovered : bool

This property holds whether the text field is hovered.

This property was introduced in QtQuick.Controls 2.1 (Qt 5.8).

See also hoverEnabled.


[read-only] implicitBackgroundHeight : real

This property holds the implicit background height.

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

This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).

See also implicitBackgroundWidth.


[read-only] implicitBackgroundWidth : real

This property holds the implicit background width.

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

This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).

See also implicitBackgroundHeight.


leftInset : real

This property holds the left inset for the background.

This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).

See also Control Layout and rightInset.


palette : palette

This property holds the palette currently set for the text field.

This property was introduced in QtQuick.Controls 2.3 (Qt 5.10).

See also Control::palette.


placeholderText : string

This property holds the hint that is displayed in the TextField before the user enters text.


placeholderTextColor : color

This property holds the color of placeholderText.

This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).

See also placeholderText.


rightInset : real

This property holds the right inset for the background.

This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).

See also Control Layout and leftInset.


topInset : real

This property holds the top inset for the background.

This property was introduced in QtQuick.Controls 2.5 (Qt 5.12).

See also Control Layout and bottomInset.


Signal Documentation

pressAndHold(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.

See also pressed and released.


pressed(event)

This signal is emitted when the text field 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.

This signal was introduced in QtQuick.Controls 2.1 (Qt 5.8).

See also released and pressAndHold.


released(event)

This signal is emitted when the text field 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.

This signal was introduced in QtQuick.Controls 2.1 (Qt 5.8).

See also pressed and pressAndHold.


© 2020 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.