QML TextArea 不会滚动
QML TextArea won't scroll
我在我的应用程序中添加了一个简单的 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
,如 documentation.
中所示
我在我的应用程序中添加了一个简单的 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
,如 documentation.