title: How to vertically center a single-line in a QTextEdit instance (PySide/PyQt)?
body: <p>I have a line editor that inherits from <code>QTextEdit</code>, and I am using it to edit view items that show rich text. The second parameter for <code>QTextEdit.setAlignment</code> is `QtAligntment' and <a href="http://pyqt.sourceforge.net/Docs/PyQt4/qtextedit.html#setAlignment" rel="nofollow noreferrer">the docs</a> say:</p>
  
  <blockquote>
    <p>Valid alignments are Qt.AlignLeft, Qt.AlignRight, Qt.AlignJustify and
    Qt.AlignCenter (which centers horizontally).</p>
  </blockquote>
  
  <p>That is, there is no native support for vertical alignment. Is there an indirect way to vertically center the text in <code>QTextEdit</code>?</p>
  
  <p><strong>Related link</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/17891129/center-the-text-of-qtextedit-horizontally-and-vertically">Center the Text of QTextEdit horizontally and vertically</a> : Unfortunately, the accepted answer uses <code>QLineEdit</code> which won't work for me.</p>
  
  <p><strong>A clue?</strong></p>
  
  <p>At the following I found a clue about how to do it in C++/Qt. I am almost able to follow it, but not quite, as it is for c++:</p>
  
  <p><a href="http://www.qtcentre.org/threads/26003-Vertical-centering-of-a-QTextEdit" rel="nofollow noreferrer">http://www.qtcentre.org/threads/26003-Vertical-centering-of-a-QTextEdit</a></p>
  
  <p>I will hack at it on my own for a couple of days and try to answer it myself, but wanted to post this now in case someone has already cracked it already or done it in a different/better way.</p>