设置QTextEdit的行高
QTextCursor textCursor = ui->textEdit->textCursor();
QTextBlockFormat textBlockFormat;
textBlockFormat.setLineHeight(40, QTextBlockFormat::FixedHeight);//设置固定行高
textCursor.setBlockFormat(textBlockFormat);
ui->textEdit->setTextCursor(textCursor);
设置QTextEdit的行间距
QTextCursor textCursor = ui->textEdit->textCursor();
QTextBlockFormat textBlockFormat;
textBlockFormat.setBottomMargin(10);
textCursor.setBlockFormat(textBlockFormat);
ui->textEdit->setTextCursor(textCursor);
参考文章:https://www.yuque.com/docs/share/149369ec-0834-4087-bcbb-72510d4df9b3