Notes on drawing text in Qt

Qt draws text directly using drawText. The function prototype is as follows:

void QPainter::drawText(const QPointF &position, const QString &text)

Examples are as follows:

Qt draws text, the position of the text:

painter->translate(width()/2,height()/2);
painter->drawText(0,0,centerText2);

As shown below:

Note: The text is drawn from the upper right of the (x, y) position, not the lower right.

Guess you like

Origin blog.csdn.net/weixin_41882459/article/details/113356285