I have my own doubts if this will work but you can give it a try

If movePosition(QTextCursor::Left) returns false then you are at the beginning of the line and if movePosition(QTextCursor::Right) returns false then you are at the end of the line.