[Interest] [Development] QTextEdit - Line Spacing

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Mon Nov 12 11:41:03 CET 2018


Il 11/11/18 17:15, coroberti . ha scritto:
> Following Allan's advise, here's something that is starting to work
> (checks omitted)
> 
> QTextDocument* doc = this->text_edit_->document();
> QTextBlock currentBlock = doc->firstBlock();
> 
>      while (currentBlock.isValid()) {
> 
>          QTextCursor cursor(currentBlock);
>          QTextBlockFormat blockFormat = currentBlock.blockFormat();
>          blockFormat.setLineHeight(200, QTextBlockFormat::ProportionalHeight);
>          cursor.setBlockFormat(blockFormat);
> 
>          currentBlock = currentBlock.next();
>      }
> 
> Thank you very much!

Isn't it simpler to use a selection approach instead?

QTextBlockFormat format;
format.setLineHeight(...);

QTextCursor cursor(textDocument);
cursor.select(QTextCursor::Document);
cursor.mergeBlockFormat(format);


My 2 c,

-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4007 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181112/0ca6f5ea/attachment.bin>


More information about the Interest mailing list