1. 程式人生 > >設置QTextEdit的行高和行間距

設置QTextEdit的行高和行間距

lin height ttext code .com nehe b- tex gin

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

設置QTextEdit的行高和行間距