Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Scroll TextArea to end
Forum Updated to NodeBB v4.3 + New Features

Scroll TextArea to end

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kDohmen
    wrote on last edited by kDohmen
    #1

    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)
                }
            }
        }
    }
    
    
    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Did you try "append":http://qt-project.org/doc/qt-5/qml-qtquick-controls-textarea.html#append-method ?

      157

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kDohmen
        wrote on last edited by
        #3

        No because I want to use property-binding. I will try that but there must me a solution for someone using property-binding.

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          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.

          157

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved