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

Elide property of Text breaks component resizing

    XMLWordPrintable

Details

    • 127c79fb7fda16b9a48ce8c425d1700d1aa7502d (qt/qtdeclarative/dev) 2fee8f1f310406af41fd104892be012d4e633b94 (qt/qtdeclarative/6.0) c24757f1b642102852beb1f62c83bfd76ca31567 (qt/tqtc-qtdeclarative/tqtc/lts-5.15), 235bbe8c6 (dev), 892576b74 (6.7)

    Description

      When the elide property of Text is set to Text.ElideRight, it is possible to break the Text component such that the text disappears and cannot reappear unless it is re-set. Using the following code, clicking on the Item area will cause the text to disappear and never reappear.

      Removing the elide value or using any other value does not reproduce this behavior.
      Also note that both width AND height must be set to 0 to reproduce the behavior. If you set only one to 0, the text does not disappear. Likewise if you set height to 0 then reset it to parent.height, THEN set width to 0 and reset it to parent.width, you cannot reproduce this behavior.

      This becomes a larger issue when dynamically creating objects that contain Text elements. The dynamically created object may have a 0 height and width at creation, especially if anchoring is being used, and then get set to valid values after completion.

      Example Code:

      import QtQuick 2.1
      
      Item {
          anchors.fill: parent
      
          Text {
              id: iText
      
              width: parent.width
              height: parent.height
              elide: Text.ElideRight
              text: 'Testing some long text that should get trimmed'
              color: 'white'
          }
      
          MouseArea {
              anchors.fill: parent
      
              onClicked: {
                  iText.height = 0;
                  iText.width = 0;
                  iText.height = parent.height;
                  iText.width = parent.width;
                  console.log( "Height: " + iText.height + "Width: " + iText.width );
              }
          }
      }
      

      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
              leonard777 Corey Pendleton
              Votes:
              7 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: