When a QTextEdit has some invisible blocks, QTextEdit::cursorForPosition() sometimes returns a QTextCursor inside an invisible block (when you click in between blocks where the invisible block would be). If you get the QRectF for this cursor, it will often not be where it is supposed to since the invisible block doesn't have valid coordinates. So if you have a QTextEdit with some invisible blocks, even just clicking around, the cursor will sometimes jump to random other blocks. I created a minimal example to show this bug. The example populates a QTextEdit with 500 blocks and makes roughly half of them invisible. If you click in between two blocks (in the margin space) where an invisible block would be, the cursor will often jump/go to random places it shouldn't be. Feel free to contact me for more information.