Scroll TextArea to end
-
Hello,
I want to make a chatmessenger-like surface. To display the incoming strings I use a TextArea.
The problem is, if the TextArea is full with lines it don't scoll. I searched around but I didn't found a solution how to set the scrolling position.
Additionally if I scroll manually down to the new messages, the TextArea jumps to the top with every new incoming message.Here my qml-File:
ColumnLayout { id: root ConfigChatVM { id: configChatVM } TextArea { readOnly: true Layout.fillHeight: true Layout.fillWidth: true text: configChatVM.history } RowLayout { Layout.fillHeight: true Layout.fillWidth: true TextInput { id: input Layout.fillHeight: true Layout.fillWidth: true font.pixelSize: 12 onEditingFinished: { if (activeFocus) { configChatVM.sendMessage(text) text = "" } } } Button { text: qsTr("Button") Layout.fillHeight: true Layout.fillWidth: false onClicked: { configChatVM.sendMessage(input.text) } } } }
-
Hi,
Did you try "append":http://qt-project.org/doc/qt-5/qml-qtquick-controls-textarea.html#append-method ?
-
I haven't come across any built-in property will always display TextArea with contents scrolled to Bottom.
Another way would be to do some math and set TextArea's flickableItem.contentY.