 <p>As documentation said:</p> <pre><code>void QTextEdit::setAlignment(Qt::Alignment a) [slot] </code></pre> <p>Sets the alignment of the current paragraph to <code>a</code>. Valid alignments are <code>Qt::AlignLeft</code>, <code>Qt::AlignRight</code>, <code>Qt::AlignJustify</code> and <code>Qt::AlignCenter</code> (which centers horizontally).</p> <p>Link: <a href="http://qt-project.org/doc/qt-5/qtextedit.html#setAlignment" rel="nofollow noreferrer">http://qt-project.org/doc/qt-5/qtextedit.html#setAlignment</a></p> <p>So as you can see you should provide some alignment to each paragraph.</p> <p>Little example:</p> <pre><code>QTextCursor cursor = ui-&gt;textEdit-&gt;textCursor(); QTextBlockFormat textBlockFormat = cursor.blockFormat(); textBlockFormat.setAlignment(Qt::AlignRight);//or another alignment cursor.mergeBlockFormat(textBlockFormat); ui-&gt;textEdit-&gt;setTextCursor(cursor); </code></pre> <p>Which result I get on my computer?</p> <p><img src="https://i.stack.imgur.com/OSTXx.png" alt="enter image description here"></p> <p>Or something closer to your question:</p> <pre><code>ui-&gt;textEdit-&gt;clear(); ui-&gt;textEdit-&gt;append("example"); ui-&gt;textEdit-&gt;append("example"); QTextCursor cursor = ui-&gt;textEdit-&gt;textCursor(); QTextBlockFormat textBlockFormat = cursor.blockFormat(); textBlockFormat.setAlignment(Qt::AlignRight); cursor.mergeBlockFormat(textBlockFormat); ui-&gt;textEdit-&gt;setTextCursor(cursor); ui-&gt;textEdit-&gt;append("example"); cursor = ui-&gt;textEdit-&gt;textCursor(); textBlockFormat = cursor.blockFormat(); textBlockFormat.setAlignment(Qt::AlignCenter); cursor.mergeBlockFormat(textBlockFormat); ui-&gt;textEdit-&gt;setTextCursor(cursor); </code></pre> <p>Result:</p> <p><img src="https://i.stack.imgur.com/4SE5t.png" alt="enter image description here"></p>