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

Text in quickcontrols2 Button renders incorrectly after button shrink

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • 5.7.0
    • Quick: Controls 2
    • None

    Description

      If a button shrinks after growing due to text length changes, the text will be displayed further to the right. Oddly the text item position is correct, but the text is rendered centred on its previous width (it appears moved to the right).
      If text alignment is set to Text.AlignLeft, the text is positioned correctly, with Text.AlignHCentre (default) and Text.AlignRight does not.

      If the text is changed again (even in something still smaller than the default button size), it renders correctly again.

      Button {
              // ok -> ok -> ok -> ok -> ok -> bad -> bad -> ok
              property var ts: ["##","####","########","############","########################","############","########","####"]
              property int count: 0
              text: ts[count]
              onClicked: count = (count + 1) % ts.length
      
              //growth direction doesn't matter at all
              //anchors.right: parent.right
              //anchors.margins: 150
              Rectangle {
                  anchors.fill: parent.contentItem
                  color: "red"
                  opacity: 0.125
              }
              //componentItem is a Text
              Component.onCompleted: {
                  //renders correctly
                  //contentItem.horizontalAlignment = Text.AlignLeft
                  
                  //renders further to right
                  //contentItem.horizontalAlignment = Text.AlignRight
              }
          }
      

      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
              raffarti Raffaele Pertile
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes