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

QTextDocument::idealWidth() reports wrong width

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P2: Important
    • None
    • 5.15.1, 5.15.2
    • GUI: Text handling
    • None
    • Linux/X11, Windows

    Description

      In general it looks like if there are object replacement characters in the document eventually rendered as pictures then idealWidth() reports too small value (enough for the text but not for the image). This wasn't the case with Qt 5.14 and before. I don't remember about Qt 5.15.0 but it's quite regularly reproducible with 5.15.1.

      I also checked my implementation of QTextObjectInterface::intrinsicSize and it always returns correct values.

      So imagine a html like

      <table><tr>
        <td><object replacement character here></td>
        <td>Any text</td>
      </tr></table>
      

      Which we set to a QTextDocument, which is then rendered from the reimplemented paint event of QFrame.
      QTextDocument::adjustSize is called in advance and QFrame is resized according to idealWidth of the document. (I tried to resize both before and after show event of QFrame, setting doc's idealWidth as QFrame width).
      In this case "Any text" can rendered over the object in the first column as if intrinsicSize of the object returned invalid small size, but intrinsicSize always returns valid sizes, so it's not the case.

      I have to notice it's not always reproducible. For example if we take the html above and the text on the right is relatively small then everything will be rendered correctly. With longer texts it starts rendering over the object.

      Example how it looks like while intrinsicSize returned 96x96 (slightly more than real size of the picture).

      I probably won't provide minimal reproducible example. Maybe someone else with the same problem will.
      But the code I tested with is there https://github.com/psi-im/psi/blob/master/src/widgets/psitiplabel.cpp

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            rion Rion
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes