After looking at this post, I did a small program to test the QLinearGradient, and it appears that that QLinearGradient does not affect the perfect horizontal and perfect vertical lines, that drawn using QPainter::drawLine(). Before I convince myself that this is a bug I wanted to check with the forum that did I miss anything?

Here is an example, note the perfect horizontal and perfect vertical line are not affected by gradient. I have tested this on
1. Qt 4.8.1, MinGw 4.6.2, Win 7 32 bit
2. Qt 5.0.1, MinGw 4.7.0, Win 7 32 bit

Here is the Qt 5.0.1 example
QLinearGradient.jpg
Qt Code:
  1. #include <QtGui>
  2. #include <QtWidgets>
  3. #include <QApplication>
  4.  
  5. class Widget : public QWidget
  6. {
  7. public:
  8. Widget(QWidget *parent = 0) : QWidget(parent) {}
  9.  
  10. protected:
  11. void paintEvent(QPaintEvent *)
  12. {
  13. v.setCoordinateMode(QGradient::ObjectBoundingMode);
  14.  
  15. h.setCoordinateMode(QGradient::ObjectBoundingMode);
  16.  
  17. QBrush vBrush(v);
  18. QBrush hBrush(h);
  19.  
  20. QPainter painter(this);
  21.  
  22. QPen p = painter.pen();
  23. p.setWidth(25);
  24.  
  25. p.setBrush(vBrush);
  26. painter.setPen(p);
  27. painter.drawLine(QPointF(100,100),QPointF( 99,200));
  28. painter.drawLine(QPointF(200,200),QPointF(200,100));
  29. painter.drawLine(QPointF(300,100),QPointF(301,200));
  30.  
  31. p.setBrush(hBrush);
  32. painter.setPen(p);
  33. painter.drawLine(QPointF(400,100),QPointF(500, 99));
  34. painter.drawLine(QPointF(400,200),QPointF(500,200));
  35. painter.drawLine(QPointF(400,300),QPointF(500,301));
  36. }
  37. };
  38.  
  39. int main(int argc, char *argv[])
  40. {
  41. QApplication a(argc, argv);
  42.  
  43. Widget * widget = new Widget;
  44. widget->setWindowTitle("QLinearGradient");
  45. widget->showMaximized();
  46.  
  47. return a.exec();
  48. }
To copy to clipboard, switch view to plain text mode