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

Text issues with eliding and padding

    XMLWordPrintable

Details

    • 56ade46b4234bb828b8e4f9a6bf83b5687bd122e

    Description

      The expected behaviour is that the last text item is rendered without any visible text, but showing the grey Rectangle child item.

      import QtQuick 2.9
      import QtQuick.Window 2.0
      
      Window {
          id: window
          visible: true
          width: 640
          height: 600
      
          property string text: "AAAAAAAAAAAaaaaaaaaaa"
      
          Column {
              Text {
                  // Unelided, no explicit size; works
                  text: window.text
      
                  leftPadding: 38
      
                  Rectangle {
                      anchors.fill: parent
                      color: "transparent"
                      border.color: "darkorange"
                  }
              }
      
              Text {
                  // Right-elided, explicit size greater than leftPadding; works
                  text: window.text
                  width: 31
                  elide: Text.ElideRight
      
                  leftPadding: 30
      
                  Rectangle {
                      width: parent.leftPadding
                      height: parent.height
                      color: "grey"
                      opacity: 0.5
                  }
      
                  Rectangle {
                      anchors.fill: parent
                      color: "transparent"
                      border.color: "darkorange"
                  }
              }
      
              Text {
                  // Right-elided, explicit size less than leftPadding; doesn't show up
                  text: window.text
                  width: 30
                  elide: Text.ElideRight
      
                  leftPadding: 40
      
                  Rectangle {
                      width: parent.leftPadding
                      height: parent.height
                      color: "grey"
                      opacity: 0.5
                  }
      
                  Rectangle {
                      anchors.fill: parent
                      color: "transparent"
                      border.color: "darkorange"
                  }
              }
          }
      }
      

      If you add a "change handler" to see the value of the implicitWidth, it's rendered, but with all of the text visible (see qt60328-rendered.png):

      onImplicitWidthChanged: print(implicitWidth)
      

      This was found in the auto tests of https://codereview.qt-project.org/#/c/190505/.

      Attachments

        Issue Links

          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
              mitch_curtis Mitch Curtis
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes