Using Painter correctly in order to draw text.
I was learning how to draw various things in Qt using painter when I arrived at the subject of text.
What I did was something like this:
QRect rec(0, 0, 20, 30);
//painter.drawText(rec, Qt::AlignLeft, "am");
So as you can see I tried using "drawText" and QTextDocument.
I noticed though that in my Mac the resulting seems better (by that I mean more crisp or antialised), while trying it on Windows the text seems more pixelated even though I set every flag I know
Why is this happening?
Also I could not find a way to alter the size of the text. Can someone tell me (or give me a link) a simple template on drawing and customising text using Painter?
I think this is related to several problems on windows.
--> QGraphicsTextItem is using an QTextDocument internal
Is there any reason you using QTextDocument.
For simple Text you could for example draw it like :
painter.drawText(QRectF(0,0,50,50),"This is yout text",opt);@
I see, thanks for the help and the link. I will admit its kind of annoying to have the text look like that on windows, in any case what can you do.
When you want the same look on windows and mac you can try to use setPixelSize on QFont :
That will ensure that the font has the same size on different platforms.
When nothing helps you could also try to generate a QPainterPath.
I will focus making the app look as I want it on unix, and the try to fix all the issues that may come up on windows. I did implement your suggestion, seems fine till now.