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!
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.
Re: How to paint a formated text in a QPainterPath object
Quote:
Originally Posted by
high_flyer
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.
Re: How to paint a formated text in a QPainterPath object
Quote:
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?
Re: How to paint a formated text in a QPainterPath object
Quote:
Originally Posted by
high_flyer
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.
Re: How to paint a formated text in a QPainterPath object
Quote:
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.