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

QML text item does not respect new width set in onLineLaidOut

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.5.0
    • 5.2.1, 5.3.2, 5.4.0
    • None
    • Ubuntu 14.04
      Mac OS X 10.10
    • 6aef31dcfbee23986646e30553937b390374ac67

    Description

      Such behavior breaks text eliding, i.e. no ellipsis appears at the end of the fitted string.

      See example bellow. Press Enter key to toggle custom layout on and off. With left and right arrows you may decrease and increase text width correspondingly and see the difference. Expectation is that the result should be the same.

      import QtQuick 2.2
      import QtQuick.Window 2.1
      
      Window {
          id: root
          visible: true
      
          property bool customLayout: false
          onCustomLayoutChanged: console.log("custom layout:", customLayout)
          property int textWidth: 111
          onTextWidthChanged: console.log("text width:", textWidth)
      
          Text {
              focus: true
              text: "one two three four five"
              width: customLayout ? parent.width : textWidth
              maximumLineCount: 1
              elide: Text.ElideRight
              onLineLaidOut:
                  if (customLayout) {
                      line.width = textWidth
                  }
      
              Rectangle {
                  width: textWidth
                  height: parent.height
                  z: parent.z - 1
                  color: "salmon"
              }
      
              Component.onCompleted: root.textWidthChanged.connect(doLayout)
      
              Keys.onReturnPressed: customLayout = !customLayout
              Keys.onRightPressed: ++textWidth
              Keys.onLeftPressed: --textWidth
          }
      }
      

      Attachments

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

        Activity

          People

            dvolosnykh Dmitry Volosnykh
            dvolosnykh Dmitry Volosnykh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes