QGLWidget Viewport Ugly Text
When using a QGLWidget as a viewport for a QGraphicsView causes fonts to be insanely ugly. I am using a QGraphicsSimpleTextItem. Is there a way to make rendered text look as nice as it does when using the default viewport?
Secondly, to work around this I am trying to render the background png-image and text off-screen into a pixmap, then adding the pixmap to the scene that is displayed on the screen. The problem is I cannot make the background transparent. Here is essentially what I am doing:
- create a QGraphicsItemGroup
- Add a QPixmap (which is a png image containing transparent parts)
- Add a QGraphicsSimpleText item on top of the QPixmap
- Add the QGraphicsItemGroup to a new QGraphicsScene
- Create a QPixmap and a QPainter
- Call QGraphicsScene::render into the QPainter.
- Add the QPainter's QPixmap to the output scene that is displayed on the screen.
The rendered text looks good again however no matter what I try, the QGraphicsScene always fills in the transparent parts of the background png with a background color. Even when I set the background color of the scene to have a 0 alpha value, I still get a background color. I also tried adding another step and putting the scene into a viewport and using setAutoFillBackground to false which did not help either. Is there something I am missing here or maybe a better way to do this? I cannot have rendered text looking like we are back in the 80's.
[EDIT: list formatting, Volker]
If you are using a QPainter to paint.. Could you turn on Anti-Aliasing.. see QPainter::RenderHint. Also, if you're scaling the text or image, then that could cause it to look ugly, if you scale a QImage, pass the Qt::TransformationMode argument and set it as Qt::SmoothTransformation. I'm not sure if this would help, but maybe you get some hint as to why its happening.
From what I have read, it is a known problem that fonts in Qt look absolutely ridiculously ugly when drawn using a QGlWidget. If I paint them in the background using a QPainter then simply use the QPixmap I generate as the text instead of a QGraphicsSimpleTextItem directly it looks as it should, however I cannot make the QPainter/QGraphicsScene draw a transparent background color into the generated QPixmap. Therefore you get a grey background filling the QPixmap behind the text. Is there a way to have it draw the background transparent? I have tried everything I could find in the API docs that seemed like it should affect the background.
I will try it out and let you know if I could get it working. The transparency in my opinion shouldn't be an issue and usually isn't (atleast with the QPainter, we do a lot of transparency in our app with QPainter with no issue). Anyways, I'll try it and get back to you.