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.
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 }
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 { // ...
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With