Results 1 to 6 of 6

Thread: How to paint a formated text in a QPainterPath object

  1. #1
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to paint a formated text in a QPainterPath object

    when used QPainter Object, I can paint a formated text like below:

    painter.addText(rect,flags,text);

    and text can contain control char like '\n'.

    while QPainterPath class does only have a simple interface like:addText(QPoint,QFont,QString).

    So, how can't add formarted text to a QPainterPath object?

    Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to paint a formated text in a QPainterPath object

    What it is you want to do?
    Why QPainter::drawText() (not addText()) is not good for you?
    Control chars such as '\n' can be used by both versions, since both use QString, in that sense, there is no difference between the two.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to paint a formated text in a QPainterPath object

    Quote Originally Posted by high_flyer View Post
    What it is you want to do?
    Why QPainter::drawText() (not addText()) is not good for you?
    Control chars such as '\n' can be used by both versions, since both use QString, in that sense, there is no difference between the two.
    I can use QPainterPath to get the text outline, while QPainter can't.

    as my tested, QPainterPath does not supoort such path.addText(myPoint,myFont,"hello\n world!"); The control char '\n' will be ignored in above statment.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to paint a formated text in a QPainterPath object

    The control char '\n' will be ignored in above statment.
    But that is not a visible character...
    Wont breaking the string in to lines and creating one path per line do what you want?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to paint a formated text in a QPainterPath object

    Quote Originally Posted by high_flyer View Post
    But that is not a visible character...
    Wont breaking the string in to lines and creating one path per line do what you want?
    That is the mathod i used just now; but what i like is QPanterPath provides interface like QPainter.

    While GDIPLUS uses Graphics and GraphicsPath like QPainter and QPainterPath, while GraphicsPath has the adding formated text interface like in Graphics. So why QPainterPath does not provide such functions.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to paint a formated text in a QPainterPath object

    So why QPainterPath does not provide such functions.
    Because they are meant for different things, this is why you have QPainter and QPainterPath.
    QPainterPath is a PATH, not a PAINTER.
    A path has nothing to do with text particularities.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QPainterPath and QPolygon
    By Muz in forum Qt Programming
    Replies: 0
    Last Post: 18th September 2009, 07:16
  2. Convertion between QLineEdit formated to Double
    By vcp in forum Qt Programming
    Replies: 4
    Last Post: 13th June 2008, 17:15
  3. Read Data in formated manner
    By rajeshs in forum Qt Programming
    Replies: 1
    Last Post: 1st January 2008, 12:28
  4. Qt text edit paint event
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 27th October 2007, 18:13
  5. How draw a rotated text in a QPainterPath?
    By iw2nhl in forum Qt Programming
    Replies: 6
    Last Post: 17th August 2007, 18:55

Tags for this Thread

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.