Ok, i have been playing around this, seeing how things render using the Qt paintEvent() function as opposed to the paintGL() one. I am seeing even more inconsistencies than before.
Since i also want to render text on the OpenGL surface, i tried the following code:
Qt Code:
  1. void MapView::paintEvent(QPaintEvent*) {
  2. QPainter painter(this);
  3.  
  4. painter.setBackground(Qt::black);
  5. painter.setPen(Qt::red);
  6. painter.drawLine(0, 0, 300, 300);
  7. painter.drawPixmap(10, 10, testImage);
  8.  
  9. QFont font("Arial", 40);
  10.  
  11. font.setStyleStrategy(QFont::ForceOutline);
  12. painter.setRenderHint(QPainter::Antialiasing);
  13. QPainterPath textPath;
  14.  
  15. textPath.addText(20, QFontMetrics(font).height()+150, font, "Hello, World");
  16. painter.setPen(QPen(Qt::cyan, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
  17. QLinearGradient gradient(0, 0, 0, 100);
  18. gradient.setColorAt(0.0, QColor(255, 0, 0));
  19. gradient.setColorAt(1.0, QColor(0, 0, 255));
  20. painter.setBrush(gradient);
  21. painter.drawPath(textPath);
  22.  
  23. painter.setPen(Qt::yellow);
  24. painter.drawText(150, 100, "Hello again");
  25. }
To copy to clipboard, switch view to plain text mode 

On the VM, the gradient is not rendered (it's just a white rectangle), but the blue outline is. But, on my physical machine, it still does not render the gradient correctly. And the plain yellow text is not yellow and looks a bit squashed up.
I also tried turning on 3D acceleration in the VM and got different results still.

Here are some screenshots to explain better:
test.png

This is quite disappointing as i had hoped to use Qt's code for rendering text and images. It looks like i will just have to use 3rd party libraries or my own code, as i have been doing in the past. Sure would have been easier doing it all using Qt.