see QTextEdit::textCursor(), and QTextCursor
(Basically, obtain a cusor for the current position, then move it back to the start of your word, skip the whitespace, and the move it (selecting text by using MoveMode QTextCursor::KeepAnchor) over the previous word. Finally grab the text by QTextCursor::selectedText().
Iirc, using the cursor obtained by QTextEdit::textCursor() would really change the text edit's selection, so you will probably need to work on a copy of the QTextCursor.)

HTH