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. Auto scrolling text view (TextEdit) to the bottom when new text is appended
QtWS25 Last Chance

Auto scrolling text view (TextEdit) to the bottom when new text is appended

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 4.6k Views
  • 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.
  • T Offline
    T Offline
    tumbledry
    wrote on 11 Mar 2017, 17:13 last edited by
    #1

    Hello,

    With pyQt5 and QML I'm trying to implement a continuously scrolling text view. As new messages arrive, I wish to append them to the text view and have the view automatically scroll down to display the new message. This would appear similar to common chat applications such as IRC or Slack.

    I've tried simply using a QTextEdit defined in QML, and using a property for the TextEdit's text field. I keep adding more characters to the text property string, which are displayed until the TextEdit's view rectangle is full -- but when the text exceeds the viewable area, scroll bars do not appear and the view does not scroll down. This surprised me because the QTextEdit docs state, "QTextEdit can display images, lists and tables. If the text is too large to view within the text edit's viewport, scroll bars will appear"

    I've tried something similar with TextArea but didn't make much progress with that either.

    • What's the right way to implement an autoscrolling text view with QML and Qt5?
    • Do I need to manipulate any properties of the TextEdit other than text when appending new messages to the view, in order to get the view to automatically scroll down to show the latest messages? If so, can this be done in QML?

    In researching this problem I've come across multiple solutions that applied to earlier versions of Qt , but don't appear to work on Qt5.

    Thanks for any assistance!

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on 12 Mar 2017, 18:18 last edited by
      #2

      Hi! Widgets and QtQuick items are not the same. QTextEdit is not the same as the QML type TextEdit. The documentation page for TextEdit can be found her: TextEdit QML Type. There it says:

      Note that the TextEdit does not implement scrolling, following the cursor, or other behaviors specific to a look-and-feel.

      But the doc page has an example for how to add scrolling / cursor following.

      1 Reply Last reply
      1

      1/2

      11 Mar 2017, 17:13

      • Login

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