Hi guys,

I would like to render text to a QPixmap and then draw the QPixmap to a QGLWidget that will be presented on screen. The reason I want to render text to the QPixmap is so that I can set the background color of the box bounding the text to be something different than the background already on the QGLWidget. Here is the code I have so far, with client being the QGLWidget and self._image being the QPixmap.
Qt Code:
  1. def show(self, client, x_pos, y_pos, width, height):
  2. glEnable(GL_TEXTURE_2D)
  3. tex_id = client.bindTexture(self._image)
  4. self._painter.begin(self._image)
  5. self._painter.fillRect(self._image.rect(), self._background_color)
  6. self._painter.setPen(self._text_color)
  7. self._painter.setFont(self._font)
  8. self._painter.drawText(self._rect, QtCore.Qt.TextExpandTabs | QtCore.Qt.TextSingleLine | \
  9. QtCore.Qt.AlignLeft, self._text)
  10. self._painter.end()
  11. glTranslate(x_pos/width, y_pos/height, 0)
  12. width_norm = self.width()/width
  13. height_norm = self.height()/height
  14. glBegin(GL_QUADS)
  15. glTexCoord(0.0, 0.0); glVertex(-width_norm, height_norm, 0.0)
  16. glTexCoord(1.0, 0.0); glVertex(width_norm, height_norm, 0.0)
  17. glTexCoord(1.0, 1.0); glVertex(width_norm, -height_norm, 0.0)
  18. glTexCoord(0.0, 1.0); glVertex(-width_norm, -height_norm, 0.0)
  19. glEnd()
  20. glTranslate(-x_pos/width, -y_pos/height, 0)
  21. client.deleteTexture(tex_id)
  22. glDisable(GL_TEXTURE_2D)
To copy to clipboard, switch view to plain text mode 
show is called as part of QGLWidget paintEvent.

All I get with this is painting unallocated memory within the extent of what should be the text, using the current OpenGL drawing color.

Any suggestions?