[Interest] [Development] QTextEdit - Line Spacing

coroberti . coroberti at gmail.com
Mon Nov 12 11:51:33 CET 2018


On Mon, Nov 12, 2018 at 12:41 PM Giuseppe D'Angelo via Interest
<interest at qt-project.org> wrote:
>
> 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

Dear Giuseppe,
Thank you for your suggestion.

I'll test it and let you and the list to know.

Kind regards,
Robert



More information about the Interest mailing list