I need to remove some paragraphs from QTextDocument. I have tried code from this topic: Remove a line/block from QTextEdit, but QTextDocument.drawContents outputs empty line in place of removed block.
# create sample document
doc = QTextDocument()
cursor = QTextCursor(doc)
cursor.movePosition(QTextCursor.End)
cursor.insertText("First line\nSecond line\nThird line")
# now remove first line
cursor = QTextCursor(doc.findBlockByLineNumber(0))
cursor.select(QTextCursor.BlockUnderCursor)
cursor.removeSelectedText()
So, how to completely remove block?