PDA

View Full Version : Why painter->setPen() doesn't work with QTextDocument?



jiveaxe
9th November 2007, 17:27
If I have this code:


...
QPainter *painter = new QPainter(this);
painter->setPen(Qt::white);
QAbstractTextDocumentLayout::PaintContext context;
QTextDocument doc;
doc.setTextWidth(220);
doc.setHtml(text);
doc.documentLayout()->draw(painter, context);


the text is drawn in black instead of white? Only if i write:


doc.setHtml("<font color=\"white\">" + text + "</font>");

it works.

Regards

jacek
9th November 2007, 17:32
QTextFormat and its descendants are resonsible for text formatting in QTextDocument, not the painter.

jiveaxe
9th November 2007, 17:37
Ok, understood.

Thanks

jacek
9th November 2007, 17:53
Of course it's the QTextFormat what is responsible for formatting, not QTextDocument. I don't know why I wrote QTextDocument. :confused: