title: Moving the cursor inside of QTextEdit
body: <p>I have a form with a <code>QTextEdit</code> on it, which is called <code>translationInput</code>. I am trying to provide the editing functionality for the user. </p>
  
  <p>This <code>QTextEdit</code> will contain HTML-formatted text. I have a set of buttons, like "<strong>bold</strong>", "<em>Italic</em>", and so on, which should add the corresponding tags into the document. If the button is pressed when no text is selected, I just want to insert a pair of tags, for example, <code>&lt;b&gt;&lt;/b&gt;</code>. If some text is selected, I want the tags to appear left and right from it.</p>
  
  <p>This works fine. However, I also want the cursor to be placed <em>before the closing tag</em> after that, so the user will be able to continue typing inside the new-added tag without needing to reposition the cursor manually. By default, the cursor appears right <em>after</em> the new-added text (so in my case, right after the closing tag).</p>
  
  <p>Here's the code that I have for the <em>Italic</em> button:</p>
  
  <pre><code>//getting the selected text(if any), and adding tags.
  QString newText = ui.translationInput-&gt;textCursor().selectedText().prepend("&lt;i&gt;").append("&lt;/i&gt;");
  //Inserting the new-formed text into the edit
  ui.translationInput-&gt;insertPlainText( newText );
  //Returning focus to the edit
  ui.translationInput-&gt;setFocus();
  //!!! Here I want to move the cursor 4 characters left to place it before the &lt;/i&gt; tag.
  ui.translationInput-&gt;textCursor().movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 4);
  </code></pre>
  
  <p>However, the last line doesn't do anything, the cursor doesn't move, even though the <code>movePosition()</code> returns <code>true</code>, which means that all of the operations were successfully completed. </p>
  
  <p>I've also tried doing this with <code>QTextCursor::PreviousCharacter</code> instead of <code>QTextCursor::Left</code>, and tried moving it before and after returning the focus to the edit, that changes nothing. </p>
  
  <p>So the question is, how do I move the cursor inside my <code>QTextEdit</code>?</p>