Quote Originally Posted by wysota View Post
I'm asking whether this conclusion comes from your internal belief that the start and end points should be forced to be part of the line
This is the expected behavior of drawing line segment with pixel-based coords, is not it? It works so in other 2d drawing libraries like Cairo/Java2D.

But in Qt I have the following inconsistent behavior:
Qt Code:
  1. void renderLine() {
  2. image.fill(qRgb(255, 255, 255));
  3. QPainter p(&image);
  4. // these line segments with red color fill start/end points
  5. p.setPen(Qt::red);
  6. p.drawLine(QPoint(7, 2), QPoint(7, 5));
  7. p.drawLine(QPoint(9, 7), QPoint(12, 7));
  8. p.drawLine(QPoint(7, 9), QPoint(7, 12));
  9. p.drawLine(QPoint(2, 7), QPoint(5, 7));
  10. p.drawLine(QPoint(5, 5), QPoint(3, 3));
  11. p.drawLine(QPoint(9, 9), QPoint(11, 11));
  12. // these line segments with blue color doesn't fill start/end points
  13. // looks like y-coord is not respected
  14. p.setPen(Qt::blue);
  15. p.drawLine(QPoint(9, 5), QPoint(11, 3));
  16. p.drawLine(QPoint(5, 9), QPoint(3, 11));
  17. }
To copy to clipboard, switch view to plain text mode 
Qt-DrawLine-Inconsistent.png
Quote Originally Posted by wysota View Post
whether you actually checked Qt's algorithm and found a flaw in it
Don't know about algorithm used in Qt and whether it has flaws, as user of the Qt I have just tried to draw something simple with QPainter::drawLine and it didn't work in expected and consistent way.

My question is: why QPainter::drawLine works so inconsistent and what can I do to get expected results from it?