PDA

View Full Version : Long text and word wrap in QPainter



TomASS
10th December 2009, 00:28
Hi,

I'ld like to print some text. Text is quite long (for example 1000 charcters). And I've text in QString text in one line (without any \n). I've tried to print it by:

QRectF textArea(marginLeft,actTop,pageWidth,actLineHegiht );
QRectF textArea3 = painter.boundingRect(textArea,Qt::TextWordWrap,tlu maczenie.at(1));
painter.drawText(textArea, Qt::TextWordWrap, tlumaczenie.at(1),&textArea3);
painter.drawRect( textArea3 );
And last code's (drawRect( textArea3 )) drawing me a multiline (I think so) area, but text is still in one line :/

Why? How to print long text?

dbzhang800
10th December 2009, 01:47
use QTextDocument

opra
11th December 2009, 12:50
Hi
I'm displaying Strings with QGraphicsSceneTextItem.
With TextItem text length can be determined:



myTextItem->setTextWidth(100);


if will break the line automaticl