QT在QGraphicsScene上绘制富文本

QT painting rich text on QGraphicsScene

本文关键字:文本 绘制 QGraphicsScene QT      更新时间:2023-10-16

我正在为图形编写非常简单的矢量工具。我有QTextEditor编辑的富文本。我也有类扩展QGraphicsScene我所有的图纸在哪里。我想以某种方式在这个场景中绘制QTextEditor的文本?我有哪些选择?

此致敬意!

您可以使用QPainter::drawtext()方法。 基本上,你会得到一个你想要绘制的区域的画家,然后使用这种方法来绘制你的文本。

 QPainter p(this);
 p.drawText(rect(), Qt::AlignCenter, "Hello World!");