QML text scrolling

I use C ++ and QML to create a nice interface. I would like to have a “console view” where a lot of time is printed in time. However, when the text of the text element or the contents of the web browser grows, the view does not "scroll down."

How can I make the text at the bottom of the text / webview element always remain visible?

I tried playing with flickable and the_webview.evaluateJavaScript + window.scrollTo, but I could not get them to do what I want. This seems like a pretty simple part of the user interface, but I'm having serious QML issues.

Thanks for the answer.

+4
source share
4 answers

funkybro answers my final decision:

function scroll_to_bottom() { flickabe_item.contentY = Math.max(0, webview_item.height - flickabe_item.height); return; } 

Thanks!

+1
source

Perhaps you should consider using a ListView and have posts as elements in a view. Then you can use ListView::positionViewAtEnd .

+4
source

Yes, I would use a Flickable containing a Text object. Whenever you add text to Text , check its paintedHeight and adjust the Flickable contentY if there is more.

+4
source

My solution was to vertically flip both content and Flickable. Thus, the text ends in the correct way and, of course, snapped to the bottom of the moving area.

This may be more efficient since the conversion is handled by OpenGL behind the scenes.

 Flickable { id: flick anchors.fill: parent contentHeight: text.height Text { id: text width: parent.width transform: Scale { yScale: -1; origin.y: text.height/2 } } transform: Scale { yScale: -1; origin.y: flick.height/2 } } 
0
source

Source: https://habr.com/ru/post/1344808/