gpt4 book ai didi

QML TextArea 不会滚动

转载 作者:行者123 更新时间:2023-12-04 01:53:29 25 4
gpt4 key购买 nike

我在我的应用程序中添加了一个简单的 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,这通常会给出次优体验。为了使独立的 TextArea 可滚动,您可以将其附加到 Flickable,如 documentation 中所示。 .

关于QML TextArea 不会滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38137863/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com