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

Text.AlignHCenter doesn't align properly under some circumstances

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.5.0
    • None

      The following code produces qtbug48145-actual.png, when I would expect qtbug48145-expected.png:

      import QtQuick 2.0
      import QtQuick.Window 2.0
      
      Window {
          width: 200
          height: 200
          visible: true
      
          Rectangle {
              id: button
              // Works
      //        implicitWidth: label.implicitWidth
              // Doesn't work
              implicitWidth: Math.max(36, label.implicitWidth)
              implicitHeight: 36
              anchors.centerIn: parent
              color: "transparent"
              border.color: "black"
      
              Component.onCompleted: print("width=",width)
      
              Text {
                  id: label
                  text: "Style me!"
                  anchors.fill: parent
                  horizontalAlignment: Text.AlignHCenter
      
                  Rectangle {
                      anchors.fill: parent
                      color: "transparent"
                      border.color: "darkorange"
                  }
              }
          }
      }
      

      Using the commented out code instead works.

        1. qtbug48145-actual.png
          2 kB
          Mitch Curtis
        2. qtbug48145-expected.png
          2 kB
          Mitch Curtis
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            aalpert Alan Alpert
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes