When drawing lines, since Qt 4.8, the result is completely flawed on the pixel level.
It appears as if there was some difference in the rounding technique used for horizontal and vertical pixel coordinates. You can see this easily when drawing a 3-pixel wide plus (i.e. a vertical line and a horizontal line, that should cross exactly in the center pixel). When moving this center pixel around, the plus distorts completely, sometimes becoming a T or an L or some other arrangement of the two lines.
The attached line-bug.tar.gz is a small demo in which a plus and a cross are drawn magnified and follow the mouse cursor. (Untar it, then qmake; make)
If you draw aliased, you see an interseting phenomenon on the cross: Move the cursor only to the right, not vertically. Watch the top left starting point of the diagonal. It doesn't move stepwise to the right as it should, but moves up, then down-right, then up, then down-right, etc.
- Happens on all graphicssystems: raster, native (X11), opengl
- Happens at least on Qt 4.8.0 and 4.8.1
- Happens in both aliased and antialiased render hint modes of QPainter
- Does not happen on Qt 4.7.4
- Does not happen when discretizing the line data before passing it to the painter, i.e. passing a QLineF().toLine() instead of a QLineF()
(This is not a valid workaround when you want to draw antialiased, because you lose floating point precision of start/end points)
The attached BugAnimation.gif shows an animation of a cross moving horizontally. The top cross is drawn with Qt 4.7.4, the bottom one with Qt 4.8.1 with identical code.
This bug may be the reason for what is reported in https://bugreports.qt-project.org/browse/QTBUG-25896, although comments (specifically by Samuel Rodal) suggest their problem might have something to do with antialiasing (or be improved by enabling it) and the graphicssystem. So maybe it is a different problem, because this isn't the case here.
I consider this a critical bug, since when you can't rely on pixel exactness of simple line drawing, everything you draw will look crooked and small shapes just like indistinguishable specks of dirt.
|For Gerrit Dashboard: QTBUG-26013
|Fixed inconsistent rounding of square cap pens.
|Fixed outline / fill inconsistencies in raster paint engine.