QPlainTextEdit:How to cancel the display of line breaks at the end of a line when the cursor is selected?
-
By default, when the text is selected across lines, a small paragraph of line breaks will be displayed at the end, just like the green box marked in the picture.
@zybzyb The screenshot is strange, normally the behavior of QPlainTextEdit when selecting multiple lines, is to extend the selection of all lines except the last up to the right edge of the viewport. Looks like you already tinkered some with it?
Anyway, what implements it is buried deep inside the implementation of Qt's text layout subsystem, and it is not easy to override. Your easiest approach would be to override
paintEvent
and paint the background over that bit. You will need to use eachQTextBlock
's (of the backingQTextDocument
)QTextLayout
to obtain the tight content rectangle for each line, and paint over everything to the left of it.