TextArea也是一个多行文本编辑器。TextArea相比texttedit,增加了占位符文本,并添加了样式定义。
import QtQuick
import QtQuick.Window
import QtQuick.Controls
Window {
id: win
width: 800
height: 600
visible: true
TextArea {
id: ta
anchors.centerIn: parent
placeholderText: qsTr("请在这里输入文本...")
background: Rectangle {
border.color: "red"
}
}
}
给TextArea加一个滚动条:
import QtQuick
import QtQuick.Window
import QtQuick.Controls
Window {
id: win
width: 800
height: 600
visible: true
ScrollView {
id: view
width: 100
height: 100
TextArea {
id: ta
placeholderText: qsTr("请在这里输入文本...")
background: Rectangle {
border.color: "red"
}
}
}
}