title: Selecting a piece of text using QTextCursor
body: <p>Having problems with selecting pieces of text using the Qt framework. For example  if i have this document : "No time for rest". And i want to select "ime for r" and delete this piece of text from the document, how should i do it using QTextCursor? Here is my code:</p>
  
  <pre><code>QTextCursor *cursor = new QTextCursor(ui-&gt;plainTextEdit-&gt;document());
  cursor-&gt;setPosition(StartPos,QTextCursor::MoveAnchor);
  cursor-&gt;setPosition(EndPos,QTextCursor::KeepAnchor);
  cursor-&gt;select(QTextCursor::LineUnderCursor);
  cursor-&gt;clearSelection();
  </code></pre>
  
  <p>Unfortunately it deletes the whole line from the text. I've tried using other selection types like  WordUnderCursor or BlockUnderCursor, but no result. Or maybe there is a better way to do it? Thanks in advance.</p>