TextField QML Type

Single-line text input field. 更多...

import 语句: import QtQuick.Controls 2.2
Since: Qt 5.7
继承: TextInput

特性

信号

详细描述

TextField is a single line text editor. TextField extends TextInput 采用 占位符文本 功能,并添加装饰。

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")
}
					

另请参阅 TextArea , Customizing TextField ,和 输入控件 .

特性文档编制

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 or height for a background item.

注意: 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).

另请参阅 Customizing TextField .

focusReason : enumeration

此特性保持最后聚焦更改的原因。

注意: This property does not indicate whether the control has active focus , but the reason why the control either gained or lost focus.

常量 描述
Qt.MouseFocusReason 发生鼠标动作。
Qt.TabFocusReason 按下 Tab 键。
Qt.BacktabFocusReason 发生 Backtab。输入可能包括 Shift 或 Control 键;如 Shift+Tab。
Qt.ActiveWindowFocusReason 窗口系统使此窗口活动或不活动。
Qt.PopupFocusReason 应用程序打开/关闭弹出窗口,抓取/释放键盘焦点。
Qt.ShortcutFocusReason 用户键入标签的好友快捷方式
Qt.MenuBarFocusReason 菜单栏获得聚焦。
Qt.OtherFocusReason 另一原因,通常特定于应用程序。

另请参阅 Item::activeFocus .

hoverEnabled : bool

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

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

另请参阅 hovered .

[read-only] hovered : bool

This property holds whether the text field is hovered.

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

另请参阅 hoverEnabled .

placeholderText : string

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


信号文档编制

void pressAndHold ( MouseEvent 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 position of the press, and which button is pressed.

另请参阅 pressed and released .

void pressed ( MouseEvent 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 position of the press, and which button is pressed.

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

另请参阅 released and pressAndHold .

void released ( MouseEvent 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 position of the press, and which button is pressed.

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

另请参阅 pressed and pressAndHold .