QML TextArea赢得';卷轴
我在应用程序中添加了一个简单的QML TextArea赢得';卷轴,qml,qtquickcontrols2,Qml,Qtquickcontrols2,我在应用程序中添加了一个简单的TextArea。不幸的是,即使文本的contentHeight绕过了它的height 代码如下: import QtQuick 2.7 import QtQuick.Controls 2.0 ApplicationWindow { id: appWindow visible: true width: 480 height: 640 TextArea{ anchors.fill: parent
TextArea
。不幸的是,即使文本的contentHeight
绕过了它的height
代码如下:
import QtQuick 2.7
import QtQuick.Controls 2.0
ApplicationWindow {
id: appWindow
visible: true
width: 480
height: 640
TextArea{
anchors.fill: parent
anchors.margins: 100
wrapMode: TextEdit.Wrap
Component.onCompleted: {
console.log("width:", width)
console.log("contentWidth:", contentWidth)
console.log("height:", height)
console.log("contentHeight:", contentHeight)
}
onTextChanged: {
console.log("width:", width)
console.log("contentWidth:", contentWidth)
console.log("height:", height)
console.log("contentHeight:", contentHeight)
}
}
}
默认情况下,
TextArea
不可滚动,主要是为了使多行编辑器成为可滚动页面的一部分,而无需嵌套Flickable
s,这通常会带来次优体验。为了使独立的TextArea
可滚动,您可以将其附加到Flickable
上,如中所示。我最初想用一个标签从我的服务器获取预定义的文本。即使在使用Flickable时,我也无法在标签上滚动:/您能在Flickable
中包含标签的代码吗?我可以在您的答案中滚动该代码吗?将Flickable::contentHeight
绑定到标签的高度。真不敢相信这么简单!非常感谢你!