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

QStaticText drawing is incorrect using rich text format

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: P2: Important P2: Important
    • None
    • 4.8.5, 5.2.0
    • GUI: Text handling
    • None
    • Windows 7
      Visual Studio 2013
      qt-everywhere-opensource-src-5.2.0 (built from source)

      I try to draw an unbounded text using QStaticText:

      QStaticText text;
      //text.setTextWidth(400); // (1)
      text.setText("The quick brown fox jumps over the lazy dog");
      //text.setTextFormat(Qt::RichText); // (2)
      painter.drawStaticText(0, 0, text);
      painter.drawRect(QRectF{{0, 0}, text.size()});
      

      Everything is fine here and I get the picture ok1.png. If I uncomment the line (1) to put some arbitrary bounds on the text width it is also ok and the picture becomes ok2.png. So, the plain text rendering is perfectly fine.
      Now if I uncomment (2) to switch to the rich text format I get bug1.png and bug2.png respectively which seems to be wrong. The expected behaviour is the same as for the plain text format. But instead I see a strange text wrapping in the case when the text width is not restricted at all ((1) commented, bug1.png), and a QStaticText::size() inconsistency with the actual text rendering in the second case when the text width is restricted but far beyond the actual text width ((1) uncommented, bug2.png).

        1. bug1.png
          2 kB
          Alexei
        2. bug2.png
          2 kB
          Alexei
        3. ok1.png
          2 kB
          Alexei
        4. ok2.png
          2 kB
          Alexei
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            esabraha Eskil Abrahamsen Blomfeldt
            grimreaper Alexei
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes