Qt:用QPainter画垂直方向的文字?

Qt: Draw text in vertical direction with QPainter?

如何使用QPainter.drawText() API来垂直显示文字?

垂直方向的含义是:

A
B
C

像下面这样:

解决方法是在每个字符之间插入尾行(\n),如下所示:

QPainter painter(this);
QString str = "ABCDEFG";
for (int i = 1; i < str.size(); i+=2)
    str.insert(i, '\n');
painter.drawText(rect(), Qt::AlignCenter ,str);

输出: