QTextEdit already has capabilities of cut,copy, paste, undo, redo.

This might help