Be careful with QPainter::drawRect etc
David Faure
faure at kde.org
Wed Sep 19 18:43:54 BST 2007
On Tuesday 18 September 2007, John Tapsell wrote:
> Hey all,
>
> I have tracked down a bugs in KFormula where the problem was that:
>
> QPainterPath rect;
> rect.addRect(0, -baseLine(), width(), baseLine() );
> painter.drawPath( rect );
>
> and
>
> painter.drawRect(0, -baseLine(), width(), baseLine() );
>
> Draw different rectangles. The reason for this is that addRect takes
> reals, and drawRect takes int. The drawRect thus loses precision, and
> draws incorrectly.
Isn't this the famous drawRect off-by-one when doing non-antialiased painting?
file://$QTDIR/doc/html/coordsys.html#aliased-painting
i.e. no bug, but documented behavior.
--
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the kde-core-devel
mailing list