Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QML text scroll

Tags:

c++

qt

webview

qml

I am using C++ and QML to create a nice interface. I would like to have a "console view", where plenty to text is printed through time. However, when the text of a text item or webview content grows, the view does not "scroll down".

How can I make the text on the bottom of the text/webview item always stay visible ?

I have tried playing with flickable and the_webview.evaluateJavaScript + window.scrollTo , but I could not get them to do what I want. This seems a fairly simple piece of UI, but I am having serious troubles to do it with QML.

Thanks for you answer.

like image 919
rodrigob Avatar asked Mar 22 '11 17:03

rodrigob


People also ask

How to make a textarea scrollable?

A TextArea is not scrollable by itself (cf Scrollable TextArea ): If you want to make a TextArea scrollable, [...] it can be placed inside a ScrollView. ScrollView { id: view width: parent.width height: 60 TextArea { text: "A B C D E F G H I J K L" } } Button { text: "scroll" onClicked: view.contentItem.contentY += 10 }

How do I customize the scroll bar of a ScrollView?

The horizontal and vertical scroll bars can be accessed and customized using the ScrollBar.horizontal and ScrollBar.vertical attached properties. The following example adjusts the scroll bar policies so that the horizontal scroll bar is always off, and the vertical scroll bar is always on. ScrollView { // ...

What is the use of ScrollView?

ScrollView provides scrolling for user-defined content. It can be used to either replace a Flickable, or to decorate an existing one. The first example demonstrates the simplest usage of ScrollView. The second example illustrates using an existing Flickable, that is, a ListView.

How is ScrollView content size calculated?

As with Flickable, there are several things to keep in mind when using ScrollView: If only a single item is used within a ScrollView, the content size is automatically calculated based on the implicit size of its contained item.


1 Answers

Yeah I'd use a Flickable containing a Text object. Whenever you add text to the Text, check its paintedHeight, and adjust the Flickable's contentY if it's got any bigger.

like image 174
funkybro Avatar answered Oct 01 '22 08:10

funkybro