I have a line editor that inherits from QTextEdit, and I am using it to edit view items that show rich text. The second parameter for QTextEdit.setAlignme
For a single-line edit centred vertically, you just need to calculate a correct fixed height.
Using the example delegate from your previous question, it can be achieved like this:
class RichTextLineEdit(QtGui.QTextEdit):
def __init__(self, parent=None):
...
margin = 1
self.document().setDocumentMargin(margin)
fontMetrics = QtGui.QFontMetrics(self.font())
height = fontMetrics.height() + (margin + self.frameWidth()) * 2
self.setFixedHeight(height)
(NB: the reimplemented sizeHint and minimumSizeHint methods are probably redundant in the original example).