Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.13.0
-
None
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"); }