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. Get scrollView scroll down automatically
Forum Updated to NodeBB v4.3 + New Features

Get scrollView scroll down automatically

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 1 Posters 164 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.
  • Q Offline
    Q Offline
    qcoderpro
    wrote on last edited by qcoderpro
    #1

    Hi all,

    In this code:

    Column {
            anchors.fill: parent
            spacing: 10
    
            TextField { id: txtField }
    
            Button {
                text: "Send"
    
                onClicked: {
                    txtArea.text += txtField.text + '\n'
                    txtField.text = ""
                }
            }
    
            ScrollView {
                width: parent.width / 2
                height: width / 2
                clip: true
                TextArea {
                    id: txtArea
                    width: 100; height: 50
                    background:
                        Rectangle { color: "lightgray" }
                }
            }
        }
    

    ScrollView normally shows the first texts it receives, not the new ones, e.g., for texts:one, two, three, four, five respectively, it display them this way:
    Capture.PNG
    That is we have to scroll down to see last message sent, "five".
    My goal is to have the scroll view go down when it receives a new text so that we scroll up (not down) when we intentionally want to view prior massages, just like a chat window.

    Is there any solution for that please?

    By the way, I tried a couple of:ScrollBar.horizontal.policys, but none worked the way expected!

    Q 1 Reply Last reply
    0
    • Q qcoderpro

      Hi all,

      In this code:

      Column {
              anchors.fill: parent
              spacing: 10
      
              TextField { id: txtField }
      
              Button {
                  text: "Send"
      
                  onClicked: {
                      txtArea.text += txtField.text + '\n'
                      txtField.text = ""
                  }
              }
      
              ScrollView {
                  width: parent.width / 2
                  height: width / 2
                  clip: true
                  TextArea {
                      id: txtArea
                      width: 100; height: 50
                      background:
                          Rectangle { color: "lightgray" }
                  }
              }
          }
      

      ScrollView normally shows the first texts it receives, not the new ones, e.g., for texts:one, two, three, four, five respectively, it display them this way:
      Capture.PNG
      That is we have to scroll down to see last message sent, "five".
      My goal is to have the scroll view go down when it receives a new text so that we scroll up (not down) when we intentionally want to view prior massages, just like a chat window.

      Is there any solution for that please?

      By the way, I tried a couple of:ScrollBar.horizontal.policys, but none worked the way expected!

      Q Offline
      Q Offline
      qcoderpro
      wrote on last edited by
      #2

      Isn't there a solution for that, please?

      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