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

QPainter::drawText handling of align Top and Bottom is backwards

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 5.13.0
    • GUI: Painting
    • None
    • Windows

    Description

      QPainter::drawText handling for AlignTop and AlignBottom are reveresd.

      Specifying top actually draws the text aligned to the bottom of the given rectangle, and bottom aligns to the top.

      If you use the code below to draw a widget, and then use a ZoomIn\Magnifier program to see what's rendered, you'll see the bug demonstrated.

      void CMyWidget::paintEvent (QPaintEvent *)

      { const int TEXT_SIZE = 14; QPainter painter (this); QFont font = painter.font(); QRect r; painter.setRenderHint (QPainter::TextAntialiasing); font.setPixelSize (TEXT_SIZE); font.setBold (true); font.setItalic (false); painter.setFont (font); painter.setPen (Qt::black); r.setCoords (10, 20, 100, 20+TEXT_SIZE-1); painter.fillRect (r, QColor (255,255,0, 128); painter.drawText (r, Qt::AlignHCenter | Qt::AlignTop, "Top text"); r.setCoords (10, 40, 100, 40+TEXT_SIZE-1); painter.fillRect (r, QColor (255,255,0, 128); painter.drawText (r, Qt::AlignHCenter | Qt::AlignTop, "Bottom text"); }

       

      Attachments

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

        Activity

          People

            vgt Eirik Aavitsland
            chrisemsen Chris Emsen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes