Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-22401

Add an optimized append() method to TextEdit

    XMLWordPrintable

Details

    • f740895a71b6b0e7df5214cafa9c7746ca960ef7

    Description

      Use-case:
      I have a QProcess that emits standard output to TextEdit in qml. As the QProcess runs, it appends messages to a TextEdit. As the TextEdit's text grows in size, performance degrades to the point of freezing the main thread.

      Issue:
      I suspect that the TextEdit recalculates its size when qml assigns new text to it. This size calculation performance degrades linearly as text length increases (which is expected.) TextEdits have no way to efficiently append/insert text into TextEdit programmatically. See example below:

      Rectangle {
          width: 360
          height: 600
      
          TextEdit {
              id: textId
      
              anchors.fill: parent
      
              function addText(newText) {
                  text += newText;
                  text += "\n";
              }
      
              //Handle signals from QProcess or something that's emitting lots of text signals
              Connections {
                  target: talker
                  onTalk: {
                      textId.addText(newText);
                  }
              }
      
          }
      }
      

      Users can easily append or insert text at the cursor position, without performance issues.

      Possible resolution:
      Add functions into TextEdit to insert/append text at position in the TextEdit's document. QWidget programmers can easily do this using QPlainTextEdit::appendPlainText().

      Attached is a example program showing the issue.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            martjone Martin Jones (closed Nokia identity) (Inactive)
            vpicaver Philip Schuchardt
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes