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

incorrect implicitWidth on centered element causes invalid text wrapping

    XMLWordPrintable

Details

    Description

      When I set the width of a Text item to implicitWidth (i.e. Layout.maximumWidth: implicitWidth) and center it in a ColumnLayout, the text will sometimes wrap even though there is plenty of space.  Changing the width of the column (by dynamically resizing the window) causes the problem to come and go; it goes on/off for each pixel that the width changes.  If I align the Text item to either left or right instead of center, then the problem goes away.  Adding one to the Text width (i.e. Layout.maximumWidth: implicitWidth + 1) alleviates the problem so that the wrapping does not occur, which leads me to believe that it's a bad calculation of implicitWidth.

      Because I can make it go away by adding one and because it goes on/off for each pixel the column width changes, my hunch is that there's a division by 2 round-off error related to centering.

      Attachments

        1. invalid_text_wrapping.png
          invalid_text_wrapping.png
          17 kB
        2. no_text_wrapping.png
          no_text_wrapping.png
          18 kB
        3. qtbug61244.zip
          2 kB
        4. text_wrap_test.qml
          0.3 kB
        For Gerrit Dashboard: QTBUG-61244
        # Subject Branch Project Status CR V

        Activity

          People

            smd Jan Arve
            giantguppy Christopher Anderson
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes