I need to render a QTextDocument formatted by a QSyntaxHighlighter to a raw window.
I figured a way via
painter->translate(x, y);
document()->documentLayout()->draw(painter, cont);
painter->translate(x, y);
QAbstractTextDocumentLayout::PaintContext cont;
document()->documentLayout()->draw(painter, cont);
To copy to clipboard, switch view to plain text mode
but this doesnt allow for centering it in a QRect.
How could i do it like drawing a plain string with a QPainter?
painter->drawText(x,y,w,h,Qt::AlignLeft, mystr);
painter->drawText(x,y,w,h,Qt::AlignLeft, mystr);
To copy to clipboard, switch view to plain text mode
thanks,
edit:
for example, this doesnt work:
document
()->drawContents
(painter,
QRect(x,y,w,h
));
document()->drawContents(painter, QRect(x,y,w,h));
To copy to clipboard, switch view to plain text mode
edit2:
Another problem is that the code in the very first code box doesnt use the font selected into QPainter...
Bookmarks