代码, 试验过在Qt5.9.5上是有效的
QString strInfo = QString("您好,世界");
QGraphicsTextItem * textItem = new QGraphicsTextItem(strInfo,this);
textItem->setTextWidth(200);
QTextBlockFormat format;
format.setAlignment(Qt::AlignCenter);
QTextCursor cursor = textItem->textCursor();
cursor.select(QTextCursor::Document);
cursor.mergeBlockFormat(format);
cursor.clearSelection();
textItem->setTextCursor(cursor);