Solved ScrollView: Scroll TextEdit to the End
-
Hi,
I have a TextEdit which I use in a ScrollView:
ScrollView { id: view anchors.fill: parent wheelEnabled: true ScrollBar.vertical.policy: ScrollBar.AlwaysOn TextEdit { id: t focus: true anchors.fill: parent text: root.log readOnly: true font.pointSize: 10 font.family: monospaceFont.name selectByMouse: true } }
how can I automatically scroll to the end if the text root.log is updated? I mean I know I can use onLogChanged, put don't know how to set the scroll position.
-
@maxwell31 Instead of using a ScrollView you could use a Flickable with attached ScrollBar and then manually set the position of the ScrollBar in your onLogChanged handler (e.g. sb.position = 1.0)
Flickable { //... TextEdit { //... } ScrollBar.vertical: ScrollBar {id: sb} }
-
Thanks. Yes, that should work. Flickable seems to have the side effect, that it is not possible anymore to select text in my TextEdit, which is also a necessary requirement. Is there a way to change this?
-
But I will make a bigger question with the detailed requirements