QPainter painter(this);
painter.drawText(rect, Qt::AlignCenter, tr("Qt\nProject"));
//https://doc.qt.io/qt-6/qpainter.html#drawText
QPixmap pix;
QPainter p(pix);
p.setFont(QFont("Consolas",10));
p.setPen(Qt::red);
p.drawText(pix->rect(),Qt::AlignCenter,"1");
QPainter 居中绘制文本 QPixmap添加文本到中间
最新推荐文章于 2023-09-19 07:55:57 发布