Quantcast
Channel: Make QT/QML TextArea scroll to bottom - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by 8-DK for Make QT/QML TextArea scroll to bottom

$
0
0

You can achieve it with Flickable or ScrollView.

changing cursor position to in TextArea will focus on that line automatically.

create a function in the text area and change focus each time text changes. You have to call it manually

 cursorPosition = length-1

oryou can directly set property

cursorPosition : length-1 

in TextArea block on each text update.

     ScrollView {            id: scrollView            height: parent.height            width: parent.width            clip: true            anchors.fill: parent            TextArea {                id: statusTextArea                Layout.preferredWidth:parent.width                Layout.fillHeight:  true                readOnly:           true                textFormat:         TextEdit.RichText                text:              "Long Text \n"                width: parent.width                height: parent.height                anchors.fill: parent                function append(strAdd)                {                    statusTextArea.text = statusTextArea.text + strAdd                    statusTextArea.cursorPosition = statusTextArea.length-1                }            }        }       Timer {            running: true            interval: 1000            repeat: true            property int iteration: 0            onTriggered:{                statusTextArea.append("Line %1\n".arg(iteration++))                statusTextArea.append("Line %1\n".arg(iteration++))             }        }

Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>