Results 1 to 7 of 7

Thread: How draw a rotated text in a QPainterPath?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jul 2007
    Posts
    35
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: How draw a rotated text in a QPainterPath?

    Thank you rajesh for the reply.
    For now I can use your suggestion.

    Anyway my full problem is how to draw a text in a rotated rectangle with QPainterPath.
    The idea is that I don't want to rotate all the QGraphicsItem, but I want to draw a rotated text inside a path with other elements in it. The result will go inside a QGraphicsPathItem.
    May be there is a better way to obtain this effect.

    Example:
    Qt Code:
    1. QPainterPath path(0, 0);
    2. path.lineTo(10, 0); // Horizontal line
    3. path.lineTo(20, 10); // 45° line
    4. path.addText(QPointF(20,10), m_font, "Hello");
    To copy to clipboard, switch view to plain text mode 

    The last line should specify the rectangle (= text size) in which to draw the text and the angle (in this example 45°), so that the text fits the rectangle and follows the previous line direction.
    Last edited by iw2nhl; 15th August 2007 at 03:41.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49

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
  •  
Qt is a trademark of The Qt Company.