void ZeTextComponent
::DrawParagraph(QPainter * painter,
const QRect & rect
) const {
painter->save();
document.setDefaultFont(mFont);
document.setHtml(getText());
document.
setPageSize(QSize(rect.
width(), rect.
height()));
context.
clip = QRect(0,
0, rect.
width(), rect.
height());
painter->translate(rect.x(), rect.y());
document.documentLayout()->draw(painter, context);
painter->restore();
}
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();
}
To copy to clipboard, switch view to plain text mode
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 ?
Bookmarks