class Window(QtGui.QDialog):

    def __init__(self):
        super(Window, self).__init__()
self.resize(600, 400)
self.mainLayout = QtGui.QVBoxLayout(self)
self.mainLayout.setMargin(10)
self.scroll = QtGui.QScrollArea()
self.scroll.setWidgetResizable(True)
self.scroll.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
self.mainLayout.addWidget(self.scroll)
scrollContents = QtGui.QWidget()
self.scroll.setWidget(scrollContents)
self.textLayout = QtGui.QVBoxLayout(scrollContents)
self.textLayout.setMargin(10)
for _ in range(5):
    text = GrowingTextEdit()
text.setMinimumHeight(50)
self.textLayout.addWidget(text)


class GrowingTextEdit(QtGui.QTextEdit):

    def __init__(self, *args, **kwargs):
        super(GrowingTextEdit, self).__init__(*args, **kwargs)
self.document().contentsChanged.connect(self.sizeChange)
self.heightMin = 0
self.heightMax = 65000

def sizeChange(self):
    docHeight = self.document().size().height()
if self.heightMin <= docHeight <= self.heightMax:
    self.setMinimumHeight(docHeight)
QWidget, такой как QTextEdit, который автоматически переносит свою высоту в свое содержимое?