Re: QTextEdit and QCompleter
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
Re: QTextEdit and QCompleter
Thanks for your reply!
I looked at the documentation for QTextEdit::textCursor() and it seems that it already returns a copy of a current cursor. If I understand correctly then, after I move the cursor back, select the previous word and store it as a QString I can just delete the obtained cursor and work on the string?