PDA

View Full Version : QGraphicsTextItem sharpness when rotated



martinn
25th February 2010, 08:57
I'm trying to use a QGraphicsTextItem to rotate a text and write it on a QGraphicsScene. The problem is that if I rotate the text it get's blurred as you can see in this image:
http://i49.tinypic.com/9j13xw.jpg

Is it possible to get a better sharpeness on the text? Should I use another font or is the text to small to get sharp?

This is the code I'm using:


QGraphicsScene *scene = new QGraphicsScene(widget);
QGraphicsTextItem *text = new QGraphicsTextItem("19.02");
text->setFont(QFont( "Arial", 3, QFont::Normal ));
text->setDefaultTextColor(QColor(0,0,0));
text->rotate(45);
scene->addItem(text);

JohannesMunk
25th February 2010, 23:34
Have you looked into aliasing? Try enabling it on your QGraphicsView


QGraphicsView::setRenderHints(QPainter::Antialiasi ng | QPainter::TextAntialiasing);
I just read, that QPainter::TextAntialiasing is enabled by default, so probably its already enabled in your case, too.

Yes, looking at your sample, with a big magnification, I can see that Antialiasing is enabled.

I guess you are beyond the limits of your screen-resolution then... Just make it bigger :->

HIH

Johannes

martinn
26th February 2010, 13:00
Thank you very much!

One question though, as you can see I set the font size to "3". I'm building for Symbian and on my Symbian device "3" is the size that works the best. But when I tried open the app in Windows "3" is very very small because of the screen resolution is much greater. The rest of my QGraphicsScene is resized can I have the same thing happen with the text so it will be larger if I have a larger screen resolution.

The same problems I have with my QLabels, setting the font with stylesheets on a QLabel to for example "3pt" looks good in Symbian but is too small with a larger screen resolution. Can I in some way make the QLabels and other widgets text scale to fit the screen resolution? Should I use something different than "pt"?

Hope you can answer my questions and thank you very much for your help!

JohannesMunk
26th February 2010, 13:13
I thought pt = points where device independant?

http://lists.trolltech.com/pipermail/qt-embedded-interest/2010-January/000778.html
(http://lists.trolltech.com/pipermail/qt-embedded-interest/2010-January/000778.html)
But, I have no experience with embedded systems.

If you can't find a platform independant solution just let the user define the font size and store/load it with QSettings, with platform specific defaults ..

Joh