多行文本输入区域。 更多...
import 语句: | import QtQuick.Controls |
继承: | TextEdit |
TextArea 是多行文本编辑器。TextArea 扩展 TextEdit 采用 占位符文本 功能,并添加装饰。
TextArea { placeholderText: qsTr("Enter description") }
TextArea is not scrollable by itself. Especially on screen-size constrained platforms, it is often preferable to make entire application pages scrollable. On such a scrollable page, a non-scrollable TextArea might behave better than nested scrollable controls. Notice, however, that in such a scenario, the background decoration of the TextArea scrolls together with the rest of the scrollable content.
If you want to make a TextArea scrollable, for example, when it covers an entire application page, it can be placed inside a ScrollView .
ScrollView { id: view anchors.fill: parent TextArea { text: "TextArea\n...\n...\n...\n...\n...\n...\n" } }
A TextArea that is placed inside a ScrollView does the following:
By default, pressing the tab key while TextArea has active focus results in a tab character being input into the control itself. To make tab pass active focus onto another item, use the attached KeyNavigation properties:
TextField { id: textField } TextArea { KeyNavigation.priority: KeyNavigation.BeforeItem KeyNavigation.tab: textField }
另请参阅 TextField , 定制 TextArea ,和 输入控件 .
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).
另请参阅 定制 TextArea .
[since QtQuick.Controls 2.5 (Qt 5.12)] bottomInset : real |
This property holds the bottom inset for the background.
该特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。
另请参阅 Control Layout and topInset .
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 .
[since QtQuick.Controls 2.1 (Qt 5.8)] hoverEnabled : bool |
This property determines whether the text area accepts hover events. The default value is
true
.
该特性在 QtQuick.Controls 2.1 (Qt 5.8) 引入。
另请参阅 hovered .
[read-only, since QtQuick.Controls 2.1 (Qt 5.8)] hovered : bool |
This property holds whether the text area is hovered.
该特性在 QtQuick.Controls 2.1 (Qt 5.8) 引入。
另请参阅 hoverEnabled .
[read-only, since QtQuick.Controls 2.5 (Qt 5.12)] implicitBackgroundHeight : real |
This property holds the implicit background height.
值等于
background ? background.implicitHeight : 0
.
该特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。
另请参阅 implicitBackgroundWidth .
[read-only, since QtQuick.Controls 2.5 (Qt 5.12)] implicitBackgroundWidth : real |
This property holds the implicit background width.
值等于
background ? background.implicitWidth : 0
.
该特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。
另请参阅 implicitBackgroundHeight .
[since QtQuick.Controls 2.5 (Qt 5.12)] leftInset : real |
This property holds the left inset for the background.
该特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。
另请参阅 Control Layout and rightInset .
placeholderText : string |
This property holds the short hint that is displayed in the text area before the user enters a value.
[since QtQuick.Controls 2.5 (Qt 5.12)] placeholderTextColor : color |
This property holds the color of placeholderText .
该特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。
另请参阅 placeholderText .
[since QtQuick.Controls 2.5 (Qt 5.12)] rightInset : real |
This property holds the right inset for the background.
该特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。
另请参阅 Control Layout and leftInset .
[since QtQuick.Controls 2.5 (Qt 5.12)] topInset : real |
This property holds the top inset for the background.
该特性在 QtQuick.Controls 2.5 (Qt 5.12) 引入。
另请参阅 Control Layout and bottomInset .
TextArea.flickable : TextArea |
This property attaches a text area to a Flickable .
另请参阅 ScrollBar , ScrollIndicator ,和 可卷动 TextArea .
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 coordinates of the press, and which button is pressed.
注意:
相应处理程序是
onPressAndHold
.
|
This signal is emitted when the text area 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.
注意:
相应处理程序是
onPressed
.
该信号在 QtQuick.Controls 2.1 (Qt 5.8) 引入。
另请参阅 released and pressAndHold .
|
This signal is emitted when the text area 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.
注意:
相应处理程序是
onReleased
.
该信号在 QtQuick.Controls 2.1 (Qt 5.8) 引入。
另请参阅 pressed and pressAndHold .