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

Add an API to get the natural width of each line in a QML Text element

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Done
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.9.8, 5.12.5, 5.13.1
    • None
    • All
    • b25c27d37a5d5dded723946900f9a518c38385de (qt/qtdeclarative/5.15)

      In some situations we need to be able to align another QML element next to a line of text that is in a `Text` element. However, this is not possible to do for multi-line text because:

      • `onLineLaidOut` gives you the full width of the Text element rather than the natural width of the current line
      • `FontMetrics` and `TextMetrics` do not support elision or text wrapping
      • `Text` does not make it possible to access the underlying `QTextLayout`

      I would like to propose a patch that adds the `naturalTextWidth` and `naturalTextRect` as read-only properties to `QQuickTextLine` so that the user can actually know how the lines are really laid out.

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            timur.kristof Timur Kristóf
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes