Hi all,
I'm trying to render text into a qimage and then draw this image into a QGLWidget. Here's a piece of code:

Qt Code:
  1. int flags = Qt::AlignCenter;
  2. QPainter tmpPainter;
  3. QImage tmpImage(textRect.width(), textRect.height(), QImage::Format_ARGB32);
  4.  
  5. tmpImg.fill(Qt::transparent);
  6. tmpPainter.begin(&tmpImg);
  7. tmpPainter.setBrush(Qt::NoBrush);
  8. tmpPainter.setPen(QColor(255, 0, 0));
  9. tmpPainter.drawText(QRect(0, 0, tmpImg.width(), tmpImg.height()), flags, myText);
  10. tmpPainter.end();
  11.  
  12. tmpImg = QGLWidget::convertToGLFormat(tmpImg);
  13. tmpImg = tmpImg.mirrored();
  14.  
  15. glPainter->drawImage(textRect, tmpImg);
To copy to clipboard, switch view to plain text mode 

This draws the text blue instead of red! Why is that? The same goes if the color is (0, 0, 255) which gives me color red instead of blue.

I'm using Qt v4.8.4

ps: the format of the qimage was initially set to QImage::Format_ARGB32_premultiplied but i've seen the code of convertToGLFormat which converts the image to Format_ARGB32.