Results 1 to 4 of 4

Thread: QGraphicsTextItem sharpness when rotated

  1. #1
    Join Date
    Feb 2010
    Posts
    51
    Thanks
    9
    Thanked 14 Times in 4 Posts

    Default QGraphicsTextItem sharpness when rotated

    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:


    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:
    Qt Code:
    1. QGraphicsScene *scene = new QGraphicsScene(widget);
    2. QGraphicsTextItem *text = new QGraphicsTextItem("19.02");
    3. text->setFont(QFont( "Arial", 3, QFont::Normal ));
    4. text->setDefaultTextColor(QColor(0,0,0));
    5. text->rotate(45);
    6. scene->addItem(text);
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to martinn for this useful post:

    Aruz (23rd August 2012)

  3. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsTextItem sharpness when rotated

    Have you looked into aliasing? Try enabling it on your QGraphicsView

    Qt Code:
    1. QGraphicsView::setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
    To copy to clipboard, switch view to plain text mode 
    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
    Last edited by JohannesMunk; 25th February 2010 at 22:40.

  4. #3
    Join Date
    Feb 2010
    Posts
    51
    Thanks
    9
    Thanked 14 Times in 4 Posts

    Default Re: QGraphicsTextItem sharpness when rotated

    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!

  5. #4
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsTextItem sharpness when rotated

    I thought pt = points where device independant?

    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

Similar Threads

  1. drawing series of rotated ellipses
    By qtn00b in forum Newbie
    Replies: 1
    Last Post: 17th December 2009, 01:51
  2. QGraphicsView, OpenGL & rotated text
    By anthon in forum Qt Programming
    Replies: 8
    Last Post: 5th December 2009, 17:05
  3. How to increase/decrease brightness/sharpness
    By rishiraj in forum Newbie
    Replies: 2
    Last Post: 21st January 2009, 06:25
  4. How draw a rotated text in a QPainterPath?
    By iw2nhl in forum Qt Programming
    Replies: 6
    Last Post: 17th August 2007, 18:55
  5. rotated labels
    By jayw710 in forum Qt Programming
    Replies: 2
    Last Post: 11th April 2006, 17:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.