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

TextArea in ScrollView not correctly rendered on ScrollView size change

    XMLWordPrintable

Details

    Description

      Please try the example code.

      Slowly drag the SplitView handle downwards: Although the ScrollView is correctly resized, the text that becomes visible is not rendered until some drag distance is reached:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Layouts 1.15
      
      Window {
        id: root
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
      
        SplitView {
          anchors.fill: parent
          orientation: Qt.Vertical
      
          ScrollView {
            SplitView.preferredHeight: 30
      
            TextArea {
              id: editor
              selectByMouse: true
              wrapMode: Text.NoWrap
              text: "Line1\nLine2\nLine3\nLine4\nLine5\nLine6\nLine7\nLine1\nLine2\nLine3\nLine4\nLine5\nLine6\nLine7\n"
            }
          }
      
          Rectangle {
            SplitView.preferredHeight: root.height - 30
            color: "blue"
          }
        }
      }
      

      It seems this has something to do with the special Flickable handling in TextArea. The following code uses a basic Flickable instead of ScrollView. Text rendering issues are gone when the TextArea.flickable attached property is not used - however cursor based scrolling then no longer works.

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Layouts 1.15
      
      Window {
        id: root
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
      
        SplitView {
          anchors.fill: parent
          orientation: Qt.Vertical
      
          Flickable {
            id: flick
            SplitView.preferredHeight: 30
      
            // if this is attached property is used to enable cursor based scrolling
            // the rendering bug occurs again
            // TextArea.flickable: editor
      
            TextArea {
              id: editor
              selectByMouse: true
              wrapMode: Text.NoWrap
              text: "Line1\nLine2\nLine3\nLine4\nLine5\nLine6\nLine7\nLine1\nLine2\nLine3\nLine4\nLine5\nLine6\nLine7\n"
            }
          }
      
          Rectangle {
            SplitView.preferredHeight: root.height - 30
            color: "blue"
          }
        }
      }
      

      Instead of the SplitView other means of layout can be used, that does not make any difference.

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            njeisecke Nils Jeisecke
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes