The coordinate system is controlled by the QPainter class. Together with the QPaintDevice and QPaintEngine classes, QPainter form the basis of Qt's painting system, Arthur. QPainter is used to perform drawing operations, QPaintDevice is an abstraction of a two-dimensional space that can be painted on using a QPainter, and QPaintEngine provides the interface that the painter uses to draw onto different types of devices.
The QPaintDevice class is the base class of objects that can be painted: Its drawing capabilities are inherited by the QWidget, QImage, QPixmap, QPicture, and QOpenGLPaintDevice classes. The default coordinate system of a paint device has its origin at the top-left corner. The x values increase to the right and the y values increase downwards. The default unit is one pixel on pixel-based devices and one point (1/72 of an inch) on printers.
QFont font = painter.font();
const QRect rectangle = QRect(0, 0, 180, 50);
painter.drawText(rectangle, 0, tr("Hello中文"), &boundingRect);
int pixelsWide = fm.horizontalAdvance("Hello中文");
int pixelsHigh = fm.height();
qDebug()<<painter.boundingRect(boundingRect,Qt::AlignLeft, "Hello中文" );
QPen pen = painter.pen();
painter.drawRect(boundingRect.adjusted(0, 0, -pen.width(), -pen.width()));
painter.drawRect(rectangle.adjusted(0, 0, -pen.width(), -pen.width()));