PDA

View Full Version : Qt 4.4 PaintContext palette



bunjee
14th May 2008, 13:53
void ZeTextComponent::DrawParagraph(QPainter * painter, const QRect & rect) const
{
painter->save();

QTextDocument document;
document.setDefaultFont(mFont);
document.setHtml(getText());
document.setPageSize(QSize(rect.width(), rect.height()));

QAbstractTextDocumentLayout::PaintContext context;
context.clip = QRect(0, 0, rect.width(), rect.height());
painter->translate(rect.x(), rect.y());
document.documentLayout()->draw(painter, context);

painter->restore();
}

This is a function drawing a text document. In Qt documentation it says that :


QPalette PaintContext::palette
This variable holds the default color that is used for the text, when no color is specified in the text.
The default value of this variable uses the application's default palette.

I'm not sure how I'm supposed to set the text document's font text ?