[Interest] Can't set line height for QPlainTextEdit

nus1998 nus1998 at yeah.net
Wed Jun 6 03:52:44 CEST 2018


Hi All,

I want to set line height for QPlainTextEdit, here is my code, but it doesn't work, the line height is always same as the font height.
btw: If I change QPlainTextEdit to QTextEdit, then it works.
my env: Qt 5.6.2 mingw version, Win 10 64 bit

#include"dialog.h"
#include"ui_dialog.h"


Dialog::Dialog(QWidget*parent):
QDialog(parent),
ui(newUi::Dialog)
{
ui->setupUi(this);


ui->edit->setPlainText("ABC\nDEF");
//ui->edit->setText("ABC\nDEF");
QTextCursortc=ui->edit->textCursor();
QTextBlockFormatfmt=tc.blockFormat();
fmt.setLineHeight(80,QTextBlockFormat::FixedHeight);
tc.select(QTextCursor::Document);
tc.setBlockFormat(fmt);
}


Dialog::~Dialog()
{
deleteui;
}


Best regards
Nus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180606/976613a3/attachment.html>


More information about the Interest mailing list