Hi, i am trying to change the background color of a couple of lines of text, the position of the block is given in startlinepos and endlinepos. The best way appears to be to do this via ExtraSelections with the FullWidthSelection property.
This works, generally, but the problem is that the last line is not properly colored completely. A workaround is to select to the start of the next block, but that fails when there is no next block. The problem is probably best visible in the screenshot. code: QList<QTextEdit::ExtraSelection> sels; > > QTextCharFormat fmt; > fmt.setProperty(QTextFormat::FullWidthSelection, true); > > QTextCursor c = txt->textCursor(); > > c.setPosition(firstlinepos, QTextCursor::MoveAnchor); > c.movePosition(QTextCursor::StartOfBlock, QTextCursor::MoveAnchor); > > c.setPosition(lastlinepos, QTextCursor::KeepAnchor); > c.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); > > sel.cursor = c; > fmt.setBackground(Qt::red); > sel.format = fmt; > sels << sel; > > txtedit->setExtraSelections(sels); > screenshot: https://i.imgur.com/iQRMDrb.png is this a bug? or do i misunderstand the meaning of "block" and "fullwidthselection" in this context? thanks,
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest