Implementing multi-selection in QTextEdit

I'm developing a QTextEdit-based editor, and I need to implement "block mode". In that mode, rectangular blocks must be selected, instead of standard continuous selection. The pic below illustrates what I mean.