TextField QML Type
Single-line text input field. 更多...
Import Statement: | import QtQuick.Controls 2.2 |
开始支持版本: | Qt 5.7 |
基类: |
属性
- background : Item
- focusReason : enumeration
- hoverEnabled : bool
- hovered : bool
- placeholderText : string
信号
- void pressAndHold(MouseEvent event)
- void pressed(MouseEvent event)
- void released(MouseEvent event)
详细描述
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")
}
参见 TextArea, Customizing TextField, and Input Controls.
属性
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).
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.
Constant | Description |
---|---|
Qt.MouseFocusReason | A mouse action occurred. |
Qt.TabFocusReason | The Tab key was pressed. |
Qt.BacktabFocusReason | A Backtab occurred. The input for this may include the Shift or Control keys; e.g. Shift+Tab. |
Qt.ActiveWindowFocusReason | The window system made this window either active or inactive. |
Qt.PopupFocusReason | The application opened/closed a pop-up that grabbed/released the keyboard focus. |
Qt.ShortcutFocusReason | The user typed a label's buddy shortcut |
Qt.MenuBarFocusReason | The menu bar took focus. |
Qt.OtherFocusReason | Another reason, usually application-specific. |
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.
参见 hovered.
This property holds whether the text field is hovered.
This QML property was introduced in QtQuick.Controls 2.1.
参见 hoverEnabled.
This property holds the hint that is displayed in the TextField before the user enters text.
信号
void pressAndHold(MouseEvent event) |
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.
参见 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.
参见 pressed and pressAndHold.