QTextDocument doc;
doc.setHtml(text);
double offsetV = doc.size().height()*0.5;
double offsetH = 0.;
painter->translate(QPointF(-offsetH, -offsetV));
doc.drawContents(painter);
painter->translate(QPointF(offsetH, offsetV));
This will give left-aligned text at the current position. For centre-aligned text use
double offsetH = doc.size().width()*0.5;or for right-aligned text
double offsetH = doc.size().width();
No comments:
Post a Comment