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

<img> align attribute in Rich vs Styled Text



    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.6.0
    • GUI: Text handling
    • None


      1) doc issue: align attribute not even listed for Rich Text on https://doc.qt.io/qt-6/richtext-html-subset.html It is listed for Styled text on https://doc.qt.io/qt-6/qml-qtquick-text.html

      2) The layout is not consistent between the Styled vs Rich text.

      // Styled text:
      // top - works
      // middle - almost works (the middle of the image is not on the baseline, but close ..)
      // bottom - seems wrong (image does not sit exactly on the baseline, but slightly bellow)

      // Rich text:
      // top - works as if middle was selected
      // middle - works as if top was selected
      // bottom - works

      In Widgets application, top and middle result in the same output. Both work as "middle".

      Test code:

      Rectangle {
          id: main
          width: 920;
          height: 480
          focus: true
          color: "#dedede"
          Text {
              font.pointSize: 32
              textFormat: Text.RichText
              text: "hello <img src=\"images/face-smile.png\" align=\"bottom\"> world"
              Rectangle {
                  color: "red"
                  opacity: 0.3
                  anchors.fill: parent

      I am following this HTML description (https://www.w3.org/TR/html401/struct/objects.html#adef-align-IMG) :

      The following values for align concern the object's position with respect to surrounding text:
      bottom: means that the bottom of the object should be vertically aligned with the current baseline. This is the default value.
      middle: means that the center of the object should be vertically aligned with the current baseline.
      top: means that the top of the object should be vertically aligned with the top of the current text line.

      Reading HTML docs, and testing on Firefox, things look as I would expect. It seems that Qt implementation needs some fixing.


        Issue Links

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



              esabraha Eskil Abrahamsen Blomfeldt
              paeglis Gatis Paeglis
              0 Vote for this issue
              1 Start watching this issue



                Gerrit Reviews

                  There are no open Gerrit changes