设置QTextEdit的行高和行间距

设置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

猜你喜欢

转载自blog.51cto.com/4754569/2323961
今日推荐